Rename isFile() to isFileSync()

This commit is contained in:
Kevin Sawicki
2013-06-12 18:21:57 -07:00
parent 86952ff85e
commit 400aa93bf3
16 changed files with 31 additions and 31 deletions

View File

@@ -180,7 +180,7 @@ describe "Config", ->
expect(fsUtils.exists(path.join(config.configDirPath, 'packages'))).toBeTruthy()
expect(fsUtils.exists(path.join(config.configDirPath, 'snippets'))).toBeTruthy()
expect(fsUtils.exists(path.join(config.configDirPath, 'themes'))).toBeTruthy()
expect(fsUtils.isFile(path.join(config.configDirPath, 'config.cson'))).toBeTruthy()
expect(fsUtils.isFileSync(path.join(config.configDirPath, 'config.cson'))).toBeTruthy()
it "copies the bundles themes to ~/.atom", ->
initializationDone = false
@@ -191,10 +191,10 @@ describe "Config", ->
waitsFor -> initializationDone
runs ->
expect(fsUtils.isFile(path.join(config.configDirPath, 'themes/atom-dark-ui/package.cson'))).toBeTruthy()
expect(fsUtils.isFile(path.join(config.configDirPath, 'themes/atom-light-ui/package.cson'))).toBeTruthy()
expect(fsUtils.isFile(path.join(config.configDirPath, 'themes/atom-dark-syntax.less'))).toBeTruthy()
expect(fsUtils.isFile(path.join(config.configDirPath, 'themes/atom-light-syntax.less'))).toBeTruthy()
expect(fsUtils.isFileSync(path.join(config.configDirPath, 'themes/atom-dark-ui/package.cson'))).toBeTruthy()
expect(fsUtils.isFileSync(path.join(config.configDirPath, 'themes/atom-light-ui/package.cson'))).toBeTruthy()
expect(fsUtils.isFileSync(path.join(config.configDirPath, 'themes/atom-dark-syntax.less'))).toBeTruthy()
expect(fsUtils.isFileSync(path.join(config.configDirPath, 'themes/atom-light-syntax.less'))).toBeTruthy()
describe ".loadUserConfig()", ->
beforeEach ->

View File

@@ -15,9 +15,9 @@ describe "install(commandPath, callback)", ->
it "symlinks the command and makes it executable", ->
fsUtils.write(commandPath, 'test')
expect(fsUtils.isFile(commandPath)).toBeTruthy()
expect(fsUtils.isFileSync(commandPath)).toBeTruthy()
expect(fsUtils.isExecutable(commandPath)).toBeFalsy()
expect(fsUtils.isFile(destinationPath)).toBeFalsy()
expect(fsUtils.isFileSync(destinationPath)).toBeFalsy()
installDone = false
installError = null
@@ -29,6 +29,6 @@ describe "install(commandPath, callback)", ->
runs ->
expect(installError).toBeNull()
expect(fsUtils.isFile(destinationPath)).toBeTruthy()
expect(fsUtils.isFileSync(destinationPath)).toBeTruthy()
expect(fs.realpathSync(destinationPath)).toBe fs.realpathSync(commandPath)
expect(fsUtils.isExecutable(destinationPath)).toBeTruthy()

View File

@@ -9,18 +9,18 @@ describe "fsUtils", ->
it "does not through an exception when the path is a binary file", ->
expect(-> fsUtils.read(require.resolve("fixtures/binary-file.png"))).not.toThrow()
describe ".isFile(path)", ->
describe ".isFileSync(path)", ->
fixturesDir = fsUtils.resolveOnLoadPath('fixtures')
it "returns true with a file path", ->
expect(fsUtils.isFile(path.join(fixturesDir, 'sample.js'))).toBe true
expect(fsUtils.isFileSync(path.join(fixturesDir, 'sample.js'))).toBe true
it "returns false with a directory path", ->
expect(fsUtils.isFile(fixturesDir)).toBe false
expect(fsUtils.isFileSync(fixturesDir)).toBe false
it "returns false with a non-existent path", ->
expect(fsUtils.isFile(path.join(fixturesDir, 'non-existent'))).toBe false
expect(fsUtils.isFile(null)).toBe false
expect(fsUtils.isFileSync(path.join(fixturesDir, 'non-existent'))).toBe false
expect(fsUtils.isFileSync(null)).toBe false
describe ".exists(path)", ->
it "returns true when path exsits", ->

View File

@@ -119,7 +119,7 @@ class AtomPackage extends Package
requireMainModule: ->
return @mainModule if @mainModule
mainModulePath = @getMainModulePath()
@mainModule = require(mainModulePath) if fsUtils.isFile(mainModulePath)
@mainModule = require(mainModulePath) if fsUtils.isFileSync(mainModulePath)
getMainModulePath: ->
return @mainModulePath if @resolvedMainModulePath

View File

@@ -18,7 +18,7 @@ class AtomTheme extends Theme
@loadStylesheet(@path)
else
metadataPath = fsUtils.resolveExtension(path.join(@path, 'package'), ['cson', 'json'])
if fsUtils.isFile(metadataPath)
if fsUtils.isFileSync(metadataPath)
stylesheetNames = fsUtils.readObject(metadataPath)?.stylesheets
if stylesheetNames
for name in stylesheetNames

View File

@@ -152,7 +152,7 @@ window.atom =
loadUserStylesheet: ->
userStylesheetPath = fsUtils.resolve(path.join(config.configDirPath, 'user'), ['css', 'less'])
if fsUtils.isFile(userStylesheetPath)
if fsUtils.isFileSync(userStylesheetPath)
userStyleesheetContents = loadStylesheet(userStylesheetPath)
applyStylesheet(userStylesheetPath, userStyleesheetContents, 'userTheme')
@@ -275,7 +275,7 @@ window.atom =
requireUserInitScript: ->
userInitScriptPath = path.join(config.configDirPath, "user.coffee")
try
require userInitScriptPath if fsUtils.isFile(userInitScriptPath)
require userInitScriptPath if fsUtils.isFileSync(userInitScriptPath)
catch error
console.error "Failed to load `#{userInitScriptPath}`", error.stack, error

View File

@@ -74,7 +74,7 @@ class TextMateGrammar
true
getScore: (path, contents) ->
contents = fsUtils.read(path) if not contents? and fsUtils.isFile(path)
contents = fsUtils.read(path) if not contents? and fsUtils.isFileSync(path)
if syntax.grammarOverrideForPath(path) is @scopeName
3

View File

@@ -14,7 +14,7 @@ class ArchiveEditSession
new ArchiveEditSession(filePath) if archive.isPathSupported(filePath)
@deserialize: ({path}={}) ->
if fsUtils.isFile(path)
if fsUtils.isFileSync(path)
new ArchiveEditSession(path)
else
console.warn "Could not build edit session for path '#{path}' because that file no longer exists"

View File

@@ -95,7 +95,7 @@ class FuzzyFinderView extends SelectList
confirmed : ({filePath}) ->
return unless filePath
if fsUtils.isFile(filePath)
if fsUtils.isFileSync(filePath)
lineNumber = @getLineNumber()
@cancel()
@openPath(filePath, lineNumber)
@@ -177,7 +177,7 @@ class FuzzyFinderView extends SelectList
populateGitStatusPaths: ->
paths = []
paths.push(filePath) for filePath, status of git.statuses when fsUtils.isFile(filePath)
paths.push(filePath) for filePath, status of git.statuses when fsUtils.isFileSync(filePath)
@setArray(paths)

View File

@@ -69,7 +69,7 @@ class PackageGeneratorView extends View
sourcePath = path.join(@getPackagePath(), relativePath)
if fsUtils.isDirectorySync(templateChildPath)
fsUtils.makeTree(sourcePath)
if fsUtils.isFile(templateChildPath)
if fsUtils.isFileSync(templateChildPath)
fsUtils.makeTree(path.dirname(sourcePath))
content = @replacePackageNamePlaceholders(fsUtils.read(templateChildPath), packageName)
fsUtils.write(sourcePath, content)

View File

@@ -5,10 +5,10 @@ path = require 'path'
module.exports =
getTagsFile: (tagsFilePath) ->
tagsFile = path.join(tagsFilePath, "tags")
return tagsFile if fsUtils.isFile(tagsFile)
return tagsFile if fsUtils.isFileSync(tagsFile)
tagsFile = path.join(tagsFilePath, "TAGS")
return tagsFile if fsUtils.isFile(tagsFile)
return tagsFile if fsUtils.isFileSync(tagsFile)
loadTags: (tagsFilePath) ->
tagsFile = @getTagsFile(tagsFilePath)

View File

@@ -72,7 +72,7 @@ class SymbolsView extends SelectList
@setError("No symbols found")
confirmed : (tag) ->
if tag.file and not fsUtils.isFile(project.resolve(tag.file))
if tag.file and not fsUtils.isFileSync(project.resolve(tag.file))
@setError('Selected file does not exist')
setTimeout((=> @setError()), 2000)
else
@@ -101,7 +101,7 @@ class SymbolsView extends SelectList
pattern = $.trim(tag.pattern?.replace(/(^^\/\^)|(\$\/$)/g, '')) # Remove leading /^ and trailing $/
return unless pattern
file = project.resolve(tag.file)
return unless fsUtils.isFile(file)
return unless fsUtils.isFileSync(file)
for line, index in fsUtils.read(file).split('\n')
return new Point(index, 0) if pattern is $.trim(line)

View File

@@ -7,7 +7,7 @@ module.exports =
getTagsFile: (project) ->
tagsFile = project.resolve("tags") or project.resolve("TAGS")
return tagsFile if fsUtils.isFile(tagsFile)
return tagsFile if fsUtils.isFileSync(tagsFile)
find: (editor) ->
word = editor.getTextInRange(editor.getCursor().getCurrentWordBufferRange())

View File

@@ -262,7 +262,7 @@ class TreeView extends ScrollView
add: ->
selectedEntry = @selectedEntry() or @root
selectedPath = selectedEntry.getPath()
directoryPath = if fsUtils.isFile(selectedPath) then path.dirname(selectedPath) else selectedPath
directoryPath = if fsUtils.isFileSync(selectedPath) then path.dirname(selectedPath) else selectedPath
relativeDirectoryPath = project.relativize(directoryPath)
relativeDirectoryPath += '/' if relativeDirectoryPath.length > 0
@@ -277,7 +277,7 @@ class TreeView extends ScrollView
pathToCreate = project.resolve(relativePath)
try
if fsUtils.exists(pathToCreate)
pathType = if fsUtils.isFile(pathToCreate) then "file" else "directory"
pathType = if fsUtils.isFileSync(pathToCreate) then "file" else "directory"
dialog.showError("Error: A #{pathType} already exists at path '#{path}'. Try a different path.")
else if endsWithDirectorySeparator
fsUtils.makeTree(pathToCreate)

View File

@@ -650,7 +650,7 @@ describe "TreeView", ->
addDialog.miniEditor.insertText(path.basename(newPath))
addDialog.trigger 'core:confirm'
expect(fsUtils.exists(newPath)).toBeTruthy()
expect(fsUtils.isFile(newPath)).toBeTruthy()
expect(fsUtils.isFileSync(newPath)).toBeTruthy()
expect(addDialog.parent()).not.toExist()
expect(rootView.getActiveView().getPath()).toBe newPath

View File

@@ -50,7 +50,7 @@ module.exports =
# Returns true if the file specified by path exists and is a
# regular file.
isFile: (path) ->
isFileSync: (path) ->
return false unless path?.length > 0
try
path? and fs.statSync(path).isFile()