mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
24 lines
529 B
JavaScript
24 lines
529 B
JavaScript
'use strict';
|
|
|
|
const path = require('path');
|
|
const fs = require('fs');
|
|
|
|
function walkDirSync(dirPath) {
|
|
let filePaths = [];
|
|
const list = fs.readdirSync(dirPath);
|
|
list.forEach((filePathParam) => {
|
|
let filePath = filePathParam;
|
|
filePath = path.join(dirPath, filePath);
|
|
const stat = fs.statSync(filePath);
|
|
if (stat && stat.isDirectory()) {
|
|
filePaths = filePaths.concat(walkDirSync(filePath));
|
|
} else {
|
|
filePaths.push(filePath);
|
|
}
|
|
});
|
|
|
|
return filePaths;
|
|
}
|
|
|
|
module.exports = walkDirSync;
|