From 400aa93bf3db06c8d2a40f99d6a4f3a0be5d420c Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 12 Jun 2013 18:21:57 -0700 Subject: [PATCH] Rename isFile() to isFileSync() --- spec/app/config-spec.coffee | 10 +++++----- spec/stdlib/command-installer-spec.coffee | 6 +++--- spec/stdlib/fs-utils-spec.coffee | 10 +++++----- src/app/atom-package.coffee | 2 +- src/app/atom-theme.coffee | 2 +- src/app/atom.coffee | 4 ++-- src/app/text-mate-grammar.coffee | 2 +- .../archive-view/lib/archive-edit-session.coffee | 2 +- src/packages/fuzzy-finder/lib/fuzzy-finder-view.coffee | 4 ++-- .../lib/package-generator-view.coffee | 2 +- src/packages/symbols-view/lib/load-tags-handler.coffee | 4 ++-- src/packages/symbols-view/lib/symbols-view.coffee | 4 ++-- src/packages/symbols-view/lib/tag-reader.coffee | 2 +- src/packages/tree-view/lib/tree-view.coffee | 4 ++-- src/packages/tree-view/spec/tree-view-spec.coffee | 2 +- src/stdlib/fs-utils.coffee | 2 +- 16 files changed, 31 insertions(+), 31 deletions(-) diff --git a/spec/app/config-spec.coffee b/spec/app/config-spec.coffee index 6da04c8da..614161f88 100644 --- a/spec/app/config-spec.coffee +++ b/spec/app/config-spec.coffee @@ -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 -> diff --git a/spec/stdlib/command-installer-spec.coffee b/spec/stdlib/command-installer-spec.coffee index 47aa100ad..ea7cf88b7 100644 --- a/spec/stdlib/command-installer-spec.coffee +++ b/spec/stdlib/command-installer-spec.coffee @@ -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() diff --git a/spec/stdlib/fs-utils-spec.coffee b/spec/stdlib/fs-utils-spec.coffee index 6c62a0631..19dd5a892 100644 --- a/spec/stdlib/fs-utils-spec.coffee +++ b/spec/stdlib/fs-utils-spec.coffee @@ -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", -> diff --git a/src/app/atom-package.coffee b/src/app/atom-package.coffee index 693738e2a..74c43cbdd 100644 --- a/src/app/atom-package.coffee +++ b/src/app/atom-package.coffee @@ -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 diff --git a/src/app/atom-theme.coffee b/src/app/atom-theme.coffee index f82b1b6d8..8679fda62 100644 --- a/src/app/atom-theme.coffee +++ b/src/app/atom-theme.coffee @@ -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 diff --git a/src/app/atom.coffee b/src/app/atom.coffee index e15f002ed..de1a958d8 100644 --- a/src/app/atom.coffee +++ b/src/app/atom.coffee @@ -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 diff --git a/src/app/text-mate-grammar.coffee b/src/app/text-mate-grammar.coffee index b224cb2b6..cad4cb0bb 100644 --- a/src/app/text-mate-grammar.coffee +++ b/src/app/text-mate-grammar.coffee @@ -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 diff --git a/src/packages/archive-view/lib/archive-edit-session.coffee b/src/packages/archive-view/lib/archive-edit-session.coffee index 5a3580124..94d6e7be9 100644 --- a/src/packages/archive-view/lib/archive-edit-session.coffee +++ b/src/packages/archive-view/lib/archive-edit-session.coffee @@ -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" diff --git a/src/packages/fuzzy-finder/lib/fuzzy-finder-view.coffee b/src/packages/fuzzy-finder/lib/fuzzy-finder-view.coffee index c684bf133..cc0a6540c 100644 --- a/src/packages/fuzzy-finder/lib/fuzzy-finder-view.coffee +++ b/src/packages/fuzzy-finder/lib/fuzzy-finder-view.coffee @@ -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) diff --git a/src/packages/package-generator/lib/package-generator-view.coffee b/src/packages/package-generator/lib/package-generator-view.coffee index 09c1cf918..a6203d3fe 100644 --- a/src/packages/package-generator/lib/package-generator-view.coffee +++ b/src/packages/package-generator/lib/package-generator-view.coffee @@ -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) diff --git a/src/packages/symbols-view/lib/load-tags-handler.coffee b/src/packages/symbols-view/lib/load-tags-handler.coffee index bf5c5a38f..a56421cef 100644 --- a/src/packages/symbols-view/lib/load-tags-handler.coffee +++ b/src/packages/symbols-view/lib/load-tags-handler.coffee @@ -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) diff --git a/src/packages/symbols-view/lib/symbols-view.coffee b/src/packages/symbols-view/lib/symbols-view.coffee index 6c1bf1f7e..19f6a3095 100644 --- a/src/packages/symbols-view/lib/symbols-view.coffee +++ b/src/packages/symbols-view/lib/symbols-view.coffee @@ -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) diff --git a/src/packages/symbols-view/lib/tag-reader.coffee b/src/packages/symbols-view/lib/tag-reader.coffee index d243535e8..3dd25995a 100644 --- a/src/packages/symbols-view/lib/tag-reader.coffee +++ b/src/packages/symbols-view/lib/tag-reader.coffee @@ -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()) diff --git a/src/packages/tree-view/lib/tree-view.coffee b/src/packages/tree-view/lib/tree-view.coffee index e827860e6..82eb05d4f 100644 --- a/src/packages/tree-view/lib/tree-view.coffee +++ b/src/packages/tree-view/lib/tree-view.coffee @@ -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) diff --git a/src/packages/tree-view/spec/tree-view-spec.coffee b/src/packages/tree-view/spec/tree-view-spec.coffee index 88337941d..45fc9e9af 100644 --- a/src/packages/tree-view/spec/tree-view-spec.coffee +++ b/src/packages/tree-view/spec/tree-view-spec.coffee @@ -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 diff --git a/src/stdlib/fs-utils.coffee b/src/stdlib/fs-utils.coffee index f2e9fdd11..af2c62fca 100644 --- a/src/stdlib/fs-utils.coffee +++ b/src/stdlib/fs-utils.coffee @@ -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()