Skip to content

Instantly share code, notes, and snippets.

@MhdAljuboori
Created December 26, 2014 15:24
Show Gist options
  • Save MhdAljuboori/1392f282613a57aa4e9b to your computer and use it in GitHub Desktop.
Save MhdAljuboori/1392f282613a57aa4e9b to your computer and use it in GitHub Desktop.
Explore Folder Using NodeJS
function printRoot (folderPath) {
console.log("----" + folderPath);
sh.cd(folderPath);
var files = sh.ls() || [];
for (var i=0; i<files.length; i++) {
var file = files[i];
if (file.match(/.*\.js/))
console.log(file);
else {
printRoot(file);
sh.cd('../');
}
}
}
printRoot(sh.pwd())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment