Skip to content

Instantly share code, notes, and snippets.

@ondrek
Created January 9, 2014 21:33
Show Gist options
  • Save ondrek/8342459 to your computer and use it in GitHub Desktop.
Save ondrek/8342459 to your computer and use it in GitHub Desktop.
Walk recursivelly in NodeJs through all folders and subfolders and get all files
var _getFiles = function(dir) {
var results = [];
filesystem.readdirSync(dir).forEach(function(file) {
file = dir+'/'+file;
var stat = filesystem.statSync(file);
if (stat && stat.isDirectory()) {
results = results.concat(_getFiles(file))
} else results.push(file);
});
return results;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment