mirror of
https://github.com/atom/atom.git
synced 2026-02-18 10:31:54 -05:00
Return an empty array when the fs-utils.list() path isn't a directory
This makes the common case of iterating over an array of paths and listing them cleaner since the return value doesn't need to be checked before it is iterated over.
This commit is contained in:
@@ -90,7 +90,7 @@ module.exports =
|
||||
# Returns an array with all the names of files contained
|
||||
# in the directory path.
|
||||
list: (rootPath, extensions) ->
|
||||
return unless @isDirectory(rootPath)
|
||||
return [] unless @isDirectory(rootPath)
|
||||
paths = fs.readdirSync(rootPath)
|
||||
paths = @filterExtensions(paths, extensions) if extensions
|
||||
paths = paths.map (path) => @join(rootPath, path)
|
||||
|
||||
Reference in New Issue
Block a user