Update fs.list to use readdirSync and filterExtensions helper

This commit is contained in:
Nathan Sobo
2013-03-20 18:43:45 -06:00
parent a5dcd71548
commit d3ead2a0d1
4 changed files with 24 additions and 17 deletions

View File

@@ -81,16 +81,10 @@ module.exports =
# Returns an array with all the names of files contained
# in the directory path.
list: (rootPath, extensions) ->
paths = []
if extensions
onPath = (path) =>
paths.push(path) if _.contains(extensions, @extension(path))
false
else
onPath = (path) =>
paths.push(path)
false
@traverseTreeSync(rootPath, onPath, onPath)
return unless @isDirectory(rootPath)
paths = fs.readdirSync(rootPath)
paths = @filterExtensions(paths, extensions) if extensions
paths = paths.map (path) => @join(rootPath, path)
paths
listAsync: (rootPath, rest...) ->