Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
NodeJS ReaddirSync Recursive
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 {
return filelist;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment