-
-
Save feload/0b89899094799c8847ac4fb468086529 to your computer and use it in GitHub Desktop.
NodeJS ReaddirSync Recursive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function readdirRecursSync(dir, filelist) { | |
filelist = filelist || []; | |
var files = fs.readdirSync(dir); | |
files.forEach(function (file) { | |
file = path.join(dir, file); | |
if (fs.statSync(file).isDirectory()) { | |
filelist = readdirRecursSync(file, filelist); | |
} else { | |
filelist.push(file); | |
} | |
}); | |
return filelist; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment