feat: use node.js module instead of

This commit is contained in:
hongarc 2020-03-05 12:09:28 +07:00
parent fd09d9c960
commit 8eaa9f285c
2 changed files with 29 additions and 39 deletions

View file

@ -1,3 +1,6 @@
var { readdirSync, lstatSync } = require('fs');
var { join } = require('path');
var escapeString = require('../util/escapeString');
var constants = require('../util/constants');
@ -56,3 +59,16 @@ exports.genParseCommand = function(regexMap, eventName) {
};
};
};
exports.readDirDeep = function(dir) {
var paths = [];
readdirSync(dir).forEach(function(path) {
var aPath = join(dir, path);
if (lstatSync(aPath).isDirectory()) {
paths.push(...exports.readDirDeep(aPath));
} else {
paths.push(aPath);
}
});
return paths;
}