Skip to content

Instantly share code, notes, and snippets.

@jbt
Last active December 14, 2015 08:08
Show Gist options
  • Save jbt/5055782 to your computer and use it in GitHub Desktop.
Save jbt/5055782 to your computer and use it in GitHub Desktop.
Super-tiny recursive directory list in nodejs, if you don't care that you're using sync functions.
var fs = require('fs');
function ls(dirname){
return [].concat.apply([], fs.readdirSync(dirname).sort().map(function(f){
f = dirname + '/' + f
return fs.statSync(f).isDirectory() ? ls(f) : f
}));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment