added ability to ignore dotfiles in readdir
This commit is contained in:
parent
3f066f8cbf
commit
e07acc92e3
11
src/Util.js
11
src/Util.js
@ -34,13 +34,22 @@ class Util {
|
||||
});
|
||||
}
|
||||
|
||||
static readdirRecursive(directory) {
|
||||
/**
|
||||
* Read directory recursively and return all file paths
|
||||
* @static
|
||||
* @param {string} directory Full path to target directory
|
||||
* @param {boolean} [ignoreDotfiles=true]
|
||||
* @return {string[]} Array with the paths to the files within the directory
|
||||
* @memberof Util
|
||||
*/
|
||||
static readdirRecursive(directory, ignoreDotfiles = true) {
|
||||
|
||||
const result = [];
|
||||
|
||||
(function read(directory) {
|
||||
const files = fs.readdirSync(directory);
|
||||
for (const file of files) {
|
||||
if (file.startsWith('.') && ignoreDotfiles) continue;
|
||||
const filePath = path.join(directory, file);
|
||||
|
||||
if (fs.statSync(filePath).isDirectory()) {
|
||||
|
Loading…
Reference in New Issue
Block a user