Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. function walkDir(root) {
  2. const stat = fs.statSync(root);
  3.  
  4. if (stat.isDirectory()) {
  5. const dirs = fs.readdirSync(root).filter(item => !item.startsWith('.'));
  6. let results = dirs.map(sub => walkDir(`${root}/${sub}`));
  7. return [].concat(...results);
  8. } else {
  9. return root;
  10. }
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement