Skip to content

Instantly share code, notes, and snippets.

@popomore
Created October 15, 2013 07:01
Show Gist options
  • Save popomore/6987639 to your computer and use it in GitHub Desktop.
Save popomore/6987639 to your computer and use it in GitHub Desktop.
function readDirs(dir) {
var result = [];
fs.readdirSync(dir)
.forEach(function(file) {
var sub = path.join(dir, file);
if (fs.statSync(sub).isDirectory()) {
result = result.concat(readDirs(sub).map(function(subFile) {
return path.join(file, subFile);
}));
} else {
result.push(file);
}
});
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment