Skip to content

Instantly share code, notes, and snippets.

@webdevwilson
Created July 17, 2019 23:26
Show Gist options
  • Save webdevwilson/eb92c66d102a6e87f281906daa227dc3 to your computer and use it in GitHub Desktop.
Save webdevwilson/eb92c66d102a6e87f281906daa227dc3 to your computer and use it in GitHub Desktop.
/**
* List the subdirectories in a directory
* @param p the path to the directory
*/
function *listDirectories(p: string) {
return new Promise((resolve, reject) => {
fs.readdir(p, (err, files) => {
files.forEach(f => {
fs.stat(f, (err, stats) => {
if(stats.isDirectory())
yield f
})
})
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment