Last active
December 14, 2015 08:08
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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