Skip to content

Instantly share code, notes, and snippets.

@ondrek
Created January 6, 2014 21:44
Show Gist options
  • Save ondrek/8290332 to your computer and use it in GitHub Desktop.
Save ondrek/8290332 to your computer and use it in GitHub Desktop.
Most elegant way of recursively get all files from folder
function walk(dir) {
var results = [];
fs.readdirSync(dir).forEach(function(file) {
file = dir+'/'+file;
var stat = fs.statSync(file);
if (stat && stat.isDirectory()) {
results = results.concat(walk(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