Skip to content

Instantly share code, notes, and snippets.

@krutoo
Last active May 4, 2018 17:05
Show Gist options
  • Save krutoo/083baf69bccc4fe29e8197ea2107ed23 to your computer and use it in GitHub Desktop.
Save krutoo/083baf69bccc4fe29e8197ea2107ed23 to your computer and use it in GitHub Desktop.
Node.js readdirRecuriveSync
import fs from 'fs';
import path from 'path';
export function readdirRecuriveSync(dir, filelist) {
filelist = filelist || [];
var files = fs.readdirSync(dir);
files.forEach(function (file) {
file = path.join(dir, file);
if (fs.statSync(file).isDirectory()) {
filelist = readdirRecuriveSync(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