Advertisement
Guest User

Untitled

a guest
May 29th, 2015
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. fs = require 'fs'
  2. path = require 'path'
  3.  
  4. getPaths = (startPath) ->
  5. dirs = [startPath] # push/shift
  6. files = []
  7. bfs = (target) ->
  8. ls = fs.readdirSync target
  9. ls = ls.filter((x)->x.indexOf(".")!=0).map((x)->path.join(target, x))
  10. dirs = dirs.concat ls.filter (x)->fs.lstatSync(x).isDirectory()
  11. files = files.concat ls.filter (x)->fs.lstatSync(x).isFile()
  12. bfs(dirs.shift()) until dirs.length==0
  13. return files
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement