diff --git a/spec/spec-suite.coffee b/spec/spec-suite.coffee index cbae9d571..0ceb5dae6 100644 --- a/spec/spec-suite.coffee +++ b/spec/spec-suite.coffee @@ -11,6 +11,6 @@ measure 'spec suite require time', -> # Run extension specs for packageDirPath in config.packageDirPaths - for packagePath in fsUtils.list(packageDirPath) + for packagePath in fsUtils.listSync(packageDirPath) for specPath in fsUtils.listTree(path.join(packagePath, "spec")) when /-spec\.coffee$/.test specPath require specPath diff --git a/spec/stdlib/fs-utils-spec.coffee b/spec/stdlib/fs-utils-spec.coffee index 19dd5a892..bddf71b57 100644 --- a/spec/stdlib/fs-utils-spec.coffee +++ b/spec/stdlib/fs-utils-spec.coffee @@ -92,27 +92,27 @@ describe "fsUtils", -> describe ".list(path, extensions)", -> it "returns the absolute paths of entries within the given directory", -> - paths = fsUtils.list(project.getPath()) + paths = fsUtils.listSync(project.getPath()) expect(paths).toContain project.resolve('css.css') expect(paths).toContain project.resolve('coffee.coffee') expect(paths).toContain project.resolve('two-hundred.txt') it "returns an empty array for paths that aren't directories or don't exist", -> - expect(fsUtils.list(project.resolve('sample.js'))).toEqual [] - expect(fsUtils.list('/non/existent/directory')).toEqual [] + expect(fsUtils.listSync(project.resolve('sample.js'))).toEqual [] + expect(fsUtils.listSync('/non/existent/directory')).toEqual [] it "can filter the paths by an optional array of file extensions", -> - paths = fsUtils.list(project.getPath(), ['.css', 'coffee']) + paths = fsUtils.listSync(project.getPath(), ['.css', 'coffee']) expect(paths).toContain project.resolve('css.css') expect(paths).toContain project.resolve('coffee.coffee') expect(path).toMatch /(css|coffee)$/ for path in paths - describe ".listAsync(path, [extensions,] callback)", -> + describe ".list(path, [extensions,] callback)", -> paths = null it "calls the callback with the absolute paths of entries within the given directory", -> waitsFor (done) -> - fsUtils.listAsync project.getPath(), (err, result) -> + fsUtils.list project.getPath(), (err, result) -> paths = result done() runs -> @@ -122,7 +122,7 @@ describe "fsUtils", -> it "can filter the paths by an optional array of file extensions", -> waitsFor (done) -> - fsUtils.listAsync project.getPath(), ['css', '.coffee'], (err, result) -> + fsUtils.list project.getPath(), ['css', '.coffee'], (err, result) -> paths = result done() runs -> diff --git a/src/app/atom-package.coffee b/src/app/atom-package.coffee index 74c43cbdd..d8ef8bdae 100644 --- a/src/app/atom-package.coffee +++ b/src/app/atom-package.coffee @@ -70,7 +70,7 @@ class AtomPackage extends Package if @metadata.keymaps @metadata.keymaps.map (name) -> fsUtils.resolve(keymapsDirPath, name, ['json', 'cson', '']) else - fsUtils.list(keymapsDirPath, ['cson', 'json']) + fsUtils.listSync(keymapsDirPath, ['cson', 'json']) loadStylesheets: -> @stylesheets = @getStylesheetPaths().map (stylesheetPath) -> [stylesheetPath, loadStylesheet(stylesheetPath)] @@ -80,18 +80,18 @@ class AtomPackage extends Package if @metadata.stylesheets @metadata.stylesheets.map (name) -> fsUtils.resolve(stylesheetDirPath, name, ['css', 'less', '']) else - fsUtils.list(stylesheetDirPath, ['css', 'less']) + fsUtils.listSync(stylesheetDirPath, ['css', 'less']) loadGrammars: -> @grammars = [] grammarsDirPath = path.join(@path, 'grammars') - for grammarPath in fsUtils.list(grammarsDirPath, ['.json', '.cson']) + for grammarPath in fsUtils.listSync(grammarsDirPath, ['.json', '.cson']) @grammars.push(TextMateGrammar.loadSync(grammarPath)) loadScopedProperties: -> @scopedProperties = [] scopedPropertiessDirPath = path.join(@path, 'scoped-properties') - for scopedPropertiesPath in fsUtils.list(scopedPropertiessDirPath, ['.json', '.cson']) + for scopedPropertiesPath in fsUtils.listSync(scopedPropertiessDirPath, ['.json', '.cson']) for selector, properties of fsUtils.readObject(scopedPropertiesPath) @scopedProperties.push([scopedPropertiesPath, selector, properties]) diff --git a/src/app/atom-theme.coffee b/src/app/atom-theme.coffee index 8679fda62..071520fd6 100644 --- a/src/app/atom-theme.coffee +++ b/src/app/atom-theme.coffee @@ -25,6 +25,6 @@ class AtomTheme extends Theme filename = fsUtils.resolveExtension(path.join(@path, name), ['.css', '.less', '']) @loadStylesheet(filename) else - @loadStylesheet(stylesheetPath) for stylesheetPath in fsUtils.list(@path, ['.css', '.less']) + @loadStylesheet(stylesheetPath) for stylesheetPath in fsUtils.listSync(@path, ['.css', '.less']) super diff --git a/src/app/atom.coffee b/src/app/atom.coffee index de1a958d8..c6d9a3a35 100644 --- a/src/app/atom.coffee +++ b/src/app/atom.coffee @@ -113,10 +113,10 @@ window.atom = packagePaths = [] for packageDirPath in config.packageDirPaths - for packagePath in fsUtils.list(packageDirPath) + for packagePath in fsUtils.listSync(packageDirPath) packagePaths.push(packagePath) if fsUtils.isDirectorySync(packagePath) - for packagePath in fsUtils.list(path.join(window.resourcePath, 'node_modules')) + for packagePath in fsUtils.listSync(path.join(window.resourcePath, 'node_modules')) packagePaths.push(packagePath) if @isInternalPackage(packagePath) _.uniq(packagePaths) @@ -141,7 +141,7 @@ window.atom = getAvailableThemePaths: -> themePaths = [] for themeDirPath in config.themeDirPaths - themePaths.push(fsUtils.list(themeDirPath, ['', '.tmTheme', '.css', 'less'])...) + themePaths.push(fsUtils.listSync(themeDirPath, ['', '.tmTheme', '.css', 'less'])...) _.uniq(themePaths) getAvailableThemeNames: -> diff --git a/src/app/directory.coffee b/src/app/directory.coffee index 421015aad..d034bf2bc 100644 --- a/src/app/directory.coffee +++ b/src/app/directory.coffee @@ -40,7 +40,7 @@ class Directory getEntries: -> directories = [] files = [] - for entryPath in fsUtils.list(@path) + for entryPath in fsUtils.listSync(@path) try stat = fs.lstatSync(entryPath) symlink = stat.isSymbolicLink() diff --git a/src/app/keymap.coffee b/src/app/keymap.coffee index 36c241feb..f8eee192a 100644 --- a/src/app/keymap.coffee +++ b/src/app/keymap.coffee @@ -43,7 +43,7 @@ class Keymap @loadDirectory(path.join(config.configDirPath, 'keymaps')) loadDirectory: (directoryPath) -> - @load(filePath) for filePath in fsUtils.list(directoryPath, ['.cson', '.json']) + @load(filePath) for filePath in fsUtils.listSync(directoryPath, ['.cson', '.json']) load: (path) -> @add(path, CSON.readFileSync(path)) diff --git a/src/app/text-mate-package.coffee b/src/app/text-mate-package.coffee index dc76822a8..f1aebc092 100644 --- a/src/app/text-mate-package.coffee +++ b/src/app/text-mate-package.coffee @@ -49,7 +49,7 @@ class TextMatePackage extends Package loadGrammars: (done) -> fsUtils.isDirectory @getSyntaxesPath(), (isDirectory) => if isDirectory - fsUtils.listAsync @getSyntaxesPath(), @legalGrammarExtensions, (error, paths) => + fsUtils.list @getSyntaxesPath(), @legalGrammarExtensions, (error, paths) => if error? console.log("Error loading grammars of TextMate package '#{@path}':", error.stack, error) done() @@ -65,7 +65,7 @@ class TextMatePackage extends Package done() loadGrammarsSync: -> - for grammarPath in fsUtils.list(@getSyntaxesPath(), @legalGrammarExtensions) + for grammarPath in fsUtils.listSync(@getSyntaxesPath(), @legalGrammarExtensions) @addGrammar(TextMateGrammar.loadSync(grammarPath)) addGrammar: (grammar) -> @@ -94,7 +94,7 @@ class TextMatePackage extends Package selector = syntax.cssSelectorFromScopeSelector(grammar.scopeName) @scopedProperties.push({selector, properties}) - for preferencePath in fsUtils.list(@getPreferencesPath()) + for preferencePath in fsUtils.listSync(@getPreferencesPath()) {scope, settings} = fsUtils.readObject(preferencePath) if properties = @propertiesFromTextMateSettings(settings) selector = syntax.cssSelectorFromScopeSelector(scope) if scope? @@ -129,7 +129,7 @@ class TextMatePackage extends Package fsUtils.isDirectory @getPreferencesPath(), (isDirectory) => return done() unless isDirectory - fsUtils.listAsync @getPreferencesPath(), (error, paths) => + fsUtils.list @getPreferencesPath(), (error, paths) => if error? console.log("Error loading preferences of TextMate package '#{@path}':", error.stack, error) done() diff --git a/src/stdlib/fs-utils.coffee b/src/stdlib/fs-utils.coffee index 95eccf0a0..a45cc51d6 100644 --- a/src/stdlib/fs-utils.coffee +++ b/src/stdlib/fs-utils.coffee @@ -66,14 +66,14 @@ module.exports = # Returns an array with all the names of files contained # in the directory path. - list: (rootPath, extensions) -> + listSync: (rootPath, extensions) -> return [] unless @isDirectorySync(rootPath) paths = fs.readdirSync(rootPath) paths = @filterExtensions(paths, extensions) if extensions paths = paths.map (path) -> Path.join(rootPath, path) paths - listAsync: (rootPath, rest...) -> + list: (rootPath, rest...) -> extensions = rest.shift() if rest.length > 1 done = rest.shift() fs.readdir rootPath, (err, paths) =>