Rename isDirectory() to isDirectorySync()

This commit is contained in:
Kevin Sawicki
2013-06-12 18:16:31 -07:00
parent bab9bd7550
commit 86952ff85e
13 changed files with 23 additions and 23 deletions

View File

@@ -7,7 +7,7 @@ describe "Git", ->
repo = null
beforeEach ->
fsUtils.remove('/tmp/.git') if fsUtils.isDirectory('/tmp/.git')
fsUtils.remove('/tmp/.git') if fsUtils.isDirectorySync('/tmp/.git')
afterEach ->
repo.destroy() if repo?.repo?

View File

@@ -85,10 +85,10 @@ window.atom =
throw new Error("No loaded package for name '#{name}'")
resolvePackagePath: (name) ->
return name if fsUtils.isDirectory(name)
return name if fsUtils.isDirectorySync(name)
packagePath = fsUtils.resolve(config.packageDirPaths..., name)
return packagePath if fsUtils.isDirectory(packagePath)
return packagePath if fsUtils.isDirectorySync(packagePath)
packagePath = path.join(window.resourcePath, 'node_modules', name)
return packagePath if @isInternalPackage(packagePath)
@@ -114,7 +114,7 @@ window.atom =
for packageDirPath in config.packageDirPaths
for packagePath in fsUtils.list(packageDirPath)
packagePaths.push(packagePath) if fsUtils.isDirectory(packagePath)
packagePaths.push(packagePath) if fsUtils.isDirectorySync(packagePath)
for packagePath in fsUtils.list(path.join(window.resourcePath, 'node_modules'))
packagePaths.push(packagePath) if @isInternalPackage(packagePath)

View File

@@ -47,7 +47,7 @@ class Directory
stat = fs.statSync(entryPath) if symlink
catch e
continue
if stat.isDirectory()
if stat.isDirectorySync()
directories.push(new Directory(entryPath, symlink))
else if stat.isFile()
files.push(new File(entryPath, symlink))

View File

@@ -21,7 +21,7 @@ class File
# symlink - A {Boolean} indicating if the path is a symlink (default: false)
constructor: (@path, @symlink=false) ->
try
if fs.statSync(@path).isDirectory()
if fs.statSync(@path).isDirectorySync()
throw new Error("#{@path} is a directory")
# Sets the path for the file.

View File

@@ -58,7 +58,7 @@ class Project
@rootDirectory?.off()
if projectPath?
directory = if fsUtils.isDirectory(projectPath) then projectPath else path.dirname(projectPath)
directory = if fsUtils.isDirectorySync(projectPath) then projectPath else path.dirname(projectPath)
@rootDirectory = new Directory(directory)
else
@rootDirectory = null

View File

@@ -47,7 +47,7 @@ class TextMatePackage extends Package
legalGrammarExtensions: ['plist', 'tmLanguage', 'tmlanguage', 'json']
loadGrammars: (done) ->
fsUtils.isDirectoryAsync @getSyntaxesPath(), (isDirectory) =>
fsUtils.isDirectory @getSyntaxesPath(), (isDirectory) =>
if isDirectory
fsUtils.listAsync @getSyntaxesPath(), @legalGrammarExtensions, (error, paths) =>
if error?
@@ -76,14 +76,14 @@ class TextMatePackage extends Package
getSyntaxesPath: ->
syntaxesPath = path.join(@path, "syntaxes")
if fsUtils.isDirectory(syntaxesPath)
if fsUtils.isDirectorySync(syntaxesPath)
syntaxesPath
else
path.join(@path, "Syntaxes")
getPreferencesPath: ->
preferencesPath = path.join(@path, "preferences")
if fsUtils.isDirectory(preferencesPath)
if fsUtils.isDirectorySync(preferencesPath)
preferencesPath
else
path.join(@path, "Preferences")
@@ -126,7 +126,7 @@ class TextMatePackage extends Package
@loadTextMatePreferenceObjects(preferenceObjects, done)
loadTextMatePreferenceObjects: (preferenceObjects, done) ->
fsUtils.isDirectoryAsync @getPreferencesPath(), (isDirectory) =>
fsUtils.isDirectory @getPreferencesPath(), (isDirectory) =>
return done() unless isDirectory
fsUtils.listAsync @getPreferencesPath(), (error, paths) =>

View File

@@ -13,7 +13,7 @@ class WindowEventHandler
@subscribe $(window), 'focus', -> $("body").removeClass('is-blurred')
@subscribe $(window), 'blur', -> $("body").addClass('is-blurred')
@subscribe $(window), 'window:open-path', (event, pathToOpen) ->
rootView?.open(pathToOpen) unless fsUtils.isDirectory(pathToOpen)
rootView?.open(pathToOpen) unless fsUtils.isDirectorySync(pathToOpen)
@subscribeToCommand $(window), 'window:toggle-full-screen', => atom.toggleFullScreen()
@subscribeToCommand $(window), 'window:close', =>

View File

@@ -67,7 +67,7 @@ class PackageGeneratorView extends View
relativePath = @replacePackageNamePlaceholders(relativePath, packageName)
sourcePath = path.join(@getPackagePath(), relativePath)
if fsUtils.isDirectory(templateChildPath)
if fsUtils.isDirectorySync(templateChildPath)
fsUtils.makeTree(sourcePath)
if fsUtils.isFile(templateChildPath)
fsUtils.makeTree(path.dirname(sourcePath))

View File

@@ -37,7 +37,7 @@ module.exports =
loadAtomSnippets: (packagePath, done) ->
snippetsDirPath = path.join(packagePath, 'snippets')
return done() unless fsUtils.isDirectory(snippetsDirPath)
return done() unless fsUtils.isDirectorySync(snippetsDirPath)
loadSnippetFile = (filename, done) =>
return done() if filename.indexOf('.') is 0
@@ -54,7 +54,7 @@ module.exports =
loadTextMateSnippets: (bundlePath, done) ->
snippetsDirPath = path.join(bundlePath, 'Snippets')
return done() unless fsUtils.isDirectory(snippetsDirPath)
return done() unless fsUtils.isDirectorySync(snippetsDirPath)
loadSnippetFile = (filename, done) =>
return done() if filename.indexOf('.') is 0

View File

@@ -111,7 +111,7 @@ describe "StatusBar", ->
describe "git branch label", ->
beforeEach ->
fsUtils.remove('/tmp/.git') if fsUtils.isDirectory('/tmp/.git')
fsUtils.remove('/tmp/.git') if fsUtils.isDirectorySync('/tmp/.git')
rootView.attachToDom()
it "displays the current branch for files in repositories", ->

View File

@@ -680,7 +680,7 @@ describe "TreeView", ->
addDialog.miniEditor.insertText("new/dir/")
addDialog.trigger 'core:confirm'
expect(fsUtils.exists(newPath)).toBeTruthy()
expect(fsUtils.isDirectory(newPath)).toBeTruthy()
expect(fsUtils.isDirectorySync(newPath)).toBeTruthy()
expect(addDialog.parent()).not.toExist()
expect(rootView.getActiveView().getPath()).not.toBe newPath
expect(treeView.find(".tree-view")).toMatchSelector(':focus')
@@ -693,7 +693,7 @@ describe "TreeView", ->
addDialog.miniEditor.insertText("new2/")
addDialog.trigger 'core:confirm'
expect(fsUtils.exists(newPath)).toBeTruthy()
expect(fsUtils.isDirectory(newPath)).toBeTruthy()
expect(fsUtils.isDirectorySync(newPath)).toBeTruthy()
expect(addDialog.parent()).not.toExist()
expect(rootView.getActiveView().getPath()).not.toBe newPath
expect(treeView.find(".tree-view")).toMatchSelector(':focus')

View File

@@ -26,7 +26,7 @@ unlinkCommand = (destinationPath, callback) ->
module.exports =
findInstallDirectory: (callback) ->
directories = ['/opt/boxen','/opt/github','/usr/local']
async.detect(directories, fsUtils.isDirectoryAsync, callback)
async.detect(directories, fsUtils.isDirectory, callback)
install: (commandPath, commandName, callback) ->
if not commandName? or _.isFunction(commandName)

View File

@@ -29,14 +29,14 @@ module.exports =
# Returns true if the file specified by path exists and is a
# directory.
isDirectory: (path) ->
isDirectorySync: (path) ->
return false unless path?.length > 0
try
fs.statSync(path).isDirectory()
catch e
false
isDirectoryAsync: (path, done) ->
isDirectory: (path, done) ->
return done(false) unless path?.length > 0
fs.exists path, (exists) ->
if exists
@@ -67,7 +67,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 @isDirectorySync(rootPath)
paths = fs.readdirSync(rootPath)
paths = @filterExtensions(paths, extensions) if extensions
paths = paths.map (path) -> Path.join(rootPath, path)
@@ -164,7 +164,7 @@ module.exports =
@makeDirectory(path)
traverseTreeSync: (rootPath, onFile, onDirectory) ->
return unless @isDirectory(rootPath)
return unless @isDirectorySync(rootPath)
traverse = (rootPath, prefix, onFile, onDirectory) ->
prefix = "#{prefix}/" if prefix