mirror of
https://github.com/atom/atom.git
synced 2026-01-22 21:38:10 -05:00
Rename list() to listSync()
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 ->
|
||||
|
||||
@@ -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])
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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: ->
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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) =>
|
||||
|
||||
Reference in New Issue
Block a user