Rename .write() to writeSync()

This commit is contained in:
Kevin Sawicki
2013-06-12 20:38:26 -07:00
parent 3e0658fe30
commit ed3a4a33e2
19 changed files with 99 additions and 99 deletions

View File

@@ -242,7 +242,7 @@ window.atom =
setWindowState: (keyPath, value) ->
windowState = @getWindowState()
_.setValueForKeyPath(windowState, keyPath, value)
fsUtils.write(@getWindowStatePath(), JSON.stringify(windowState))
fsUtils.writeSync(@getWindowStatePath(), JSON.stringify(windowState))
windowState
getWindowState: (keyPath) ->

View File

@@ -1605,7 +1605,7 @@ class Editor extends View
saveDebugSnapshot: ->
atom.showSaveDialog (path) =>
fsUtils.write(path, @getDebugSnapshot()) if path
fsUtils.writeSync(path, @getDebugSnapshot()) if path
getDebugSnapshot: ->
[

View File

@@ -46,7 +46,7 @@ class File
write: (text) ->
previouslyExisted = @exists()
@cachedContents = text
fsUtils.write(@getPath(), text)
fsUtils.writeSync(@getPath(), text)
@subscribeToNativeChangeEvents() if not previouslyExisted and @subscriptionCount() > 0
# Reads the file.

View File

@@ -46,7 +46,7 @@ class FileView extends View
@logError("Error creating temp directory: #{tempDirPath}", error)
else
tempFilePath = path.join(tempDirPath, path.basename(@archivePath), @entry.getName())
fsUtils.writeAsync tempFilePath, contents, (error) ->
fsUtils.write tempFilePath, contents, (error) ->
if error?
@logError("Error writing to #{tempFilePath}", error)
else

View File

@@ -240,15 +240,15 @@ describe 'FuzzyFinder', ->
editor = rootView.getActiveView()
originalText = editor.getText()
originalPath = editor.getPath()
fsUtils.write(originalPath, 'making a change for the better')
fsUtils.writeSync(originalPath, 'making a change for the better')
git.getPathStatus(originalPath)
newPath = project.resolve('newsample.js')
fsUtils.write(newPath, '')
fsUtils.writeSync(newPath, '')
git.getPathStatus(newPath)
afterEach ->
fsUtils.write(originalPath, originalText)
fsUtils.writeSync(originalPath, originalText)
fsUtils.remove(newPath) if fsUtils.exists(newPath)
it "displays all new and modified paths", ->
@@ -370,7 +370,7 @@ describe 'FuzzyFinder', ->
beforeEach ->
ignoreFile = path.join(project.getPath(), '.gitignore')
fsUtils.write(ignoreFile, 'sample.js')
fsUtils.writeSync(ignoreFile, 'sample.js')
config.set("core.excludeVcsIgnoredPaths", true)
afterEach ->
@@ -504,10 +504,10 @@ describe 'FuzzyFinder', ->
originalText = editor.getText()
originalPath = editor.getPath()
newPath = project.resolve('newsample.js')
fsUtils.write(newPath, '')
fsUtils.writeSync(newPath, '')
afterEach ->
fsUtils.write(originalPath, originalText)
fsUtils.writeSync(originalPath, originalText)
fsUtils.remove(newPath) if fsUtils.exists(newPath)
describe "when a modified file is shown in the list", ->

View File

@@ -72,7 +72,7 @@ class PackageGeneratorView extends View
if fsUtils.isFileSync(templateChildPath)
fsUtils.makeTree(path.dirname(sourcePath))
content = @replacePackageNamePlaceholders(fsUtils.read(templateChildPath), packageName)
fsUtils.write(sourcePath, content)
fsUtils.writeSync(sourcePath, content)
replacePackageNamePlaceholders: (string, packageName) ->
placeholderRegex = /__(?:(package-name)|([pP]ackageName)|(package_name))__/g

View File

@@ -59,7 +59,7 @@ describe "StatusBar", ->
describe "when the buffer content has changed from the content on disk", ->
it "disables the buffer modified indicator on save", ->
filePath = "/tmp/atom-whitespace.txt"
fsUtils.write(filePath, "")
fsUtils.writeSync(filePath, "")
rootView.open(filePath)
expect(statusBar.bufferModified.text()).toBe ''
editor.insertText("\n")
@@ -132,21 +132,21 @@ describe "StatusBar", ->
beforeEach ->
filePath = require.resolve('fixtures/git/working-dir/file.txt')
newPath = path.join(fsUtils.resolveOnLoadPath('fixtures/git/working-dir'), 'new.txt')
fsUtils.write(newPath, "I'm new here")
fsUtils.writeSync(newPath, "I'm new here")
ignoredPath = path.join(fsUtils.resolveOnLoadPath('fixtures/git/working-dir'), 'ignored.txt')
fsUtils.write(ignoredPath, 'ignored.txt')
fsUtils.writeSync(ignoredPath, 'ignored.txt')
git.getPathStatus(filePath)
git.getPathStatus(newPath)
originalPathText = fsUtils.read(filePath)
rootView.attachToDom()
afterEach ->
fsUtils.write(filePath, originalPathText)
fsUtils.writeSync(filePath, originalPathText)
fsUtils.remove(newPath) if fsUtils.exists(newPath)
fsUtils.remove(ignoredPath) if fsUtils.exists(ignoredPath)
it "displays the modified icon for a changed file", ->
fsUtils.write(filePath, "i've changed for the worse")
fsUtils.writeSync(filePath, "i've changed for the worse")
git.getPathStatus(filePath)
rootView.open(filePath)
expect(statusBar.gitStatusIcon).toHaveClass('modified-status-icon')
@@ -164,16 +164,16 @@ describe "StatusBar", ->
expect(statusBar.gitStatusIcon).toHaveClass('ignored-status-icon')
it "updates when a status-changed event occurs", ->
fsUtils.write(filePath, "i've changed for the worse")
fsUtils.writeSync(filePath, "i've changed for the worse")
git.getPathStatus(filePath)
rootView.open(filePath)
expect(statusBar.gitStatusIcon).toHaveClass('modified-status-icon')
fsUtils.write(filePath, originalPathText)
fsUtils.writeSync(filePath, originalPathText)
git.getPathStatus(filePath)
expect(statusBar.gitStatusIcon).not.toHaveClass('modified-status-icon')
it "displays the diff stat for modified files", ->
fsUtils.write(filePath, "i've changed for the worse")
fsUtils.writeSync(filePath, "i've changed for the worse")
git.getPathStatus(filePath)
rootView.open(filePath)
expect(statusBar.gitStatusIcon).toHaveText('+1,-1')

View File

@@ -285,7 +285,7 @@ class TreeView extends ScrollView
@entryForPath(pathToCreate).buildEntries()
@selectEntryForPath(pathToCreate)
else
fsUtils.write(pathToCreate, "")
fsUtils.writeSync(pathToCreate, "")
rootView.open(pathToCreate)
dialog.close()
catch e

View File

@@ -603,7 +603,7 @@ describe "TreeView", ->
filePath = path.join(dirPath, "test-file.txt")
fsUtils.makeDirectory(rootDirPath)
fsUtils.makeDirectory(dirPath)
fsUtils.write(filePath, "doesn't matter")
fsUtils.writeSync(filePath, "doesn't matter")
project.setPath(rootDirPath)
@@ -663,7 +663,7 @@ describe "TreeView", ->
describe "when a file already exists at that location", ->
it "shows an error message and does not close the dialog", ->
newPath = path.join(dirPath, "new-test-file.txt")
fsUtils.write(newPath, '')
fsUtils.writeSync(newPath, '')
addDialog.miniEditor.insertText(path.basename(newPath))
addDialog.trigger 'core:confirm'
@@ -818,7 +818,7 @@ describe "TreeView", ->
describe "when a file or directory already exists at the target path", ->
it "shows an error message and does not close the dialog", ->
runs ->
fsUtils.write(path.join(rootDirPath, 'target.txt'), '')
fsUtils.writeSync(path.join(rootDirPath, 'target.txt'), '')
newPath = path.join(rootDirPath, 'target.txt')
moveDialog.miniEditor.setText(newPath)
@@ -848,7 +848,7 @@ describe "TreeView", ->
beforeEach ->
dotFilePath = path.join(dirPath, ".dotfile")
fsUtils.write(dotFilePath, "dot")
fsUtils.writeSync(dotFilePath, "dot")
dirView.collapse()
dirView.expand()
dotFileView = treeView.find('.file:contains(.dotfile)').view()
@@ -893,7 +893,7 @@ describe "TreeView", ->
runs ->
expect(fsUtils.exists(temporaryFilePath)).toBeFalsy()
entriesCountBefore = treeView.root.entries.find('.entry').length
fsUtils.write temporaryFilePath, 'hi'
fsUtils.writeSync temporaryFilePath, 'hi'
waitsFor "directory view contens to refresh", ->
treeView.root.entries.find('.entry').length == entriesCountBefore + 1
@@ -911,7 +911,7 @@ describe "TreeView", ->
beforeEach ->
ignoreFile = path.join(fsUtils.resolveOnLoadPath('fixtures/tree-view'), '.gitignore')
fsUtils.write(ignoreFile, 'tree-view.js')
fsUtils.writeSync(ignoreFile, 'tree-view.js')
config.set "core.hideGitIgnoredFiles", false
afterEach ->
@@ -934,16 +934,16 @@ describe "TreeView", ->
beforeEach ->
config.set "core.hideGitIgnoredFiles", false
ignoreFile = path.join(fsUtils.resolveOnLoadPath('fixtures/tree-view'), '.gitignore')
fsUtils.write(ignoreFile, 'tree-view.js')
fsUtils.writeSync(ignoreFile, 'tree-view.js')
git.getPathStatus(ignoreFile)
newFile = path.join(fsUtils.resolveOnLoadPath('fixtures/tree-view/dir2'), 'new2')
fsUtils.write(newFile, '')
fsUtils.writeSync(newFile, '')
git.getPathStatus(newFile)
modifiedFile = path.join(fsUtils.resolveOnLoadPath('fixtures/tree-view/dir1'), 'file1')
originalFileContent = fsUtils.read(modifiedFile)
fsUtils.write modifiedFile, 'ch ch changes'
fsUtils.writeSync modifiedFile, 'ch ch changes'
git.getPathStatus(modifiedFile)
treeView.updateRoot()
@@ -952,7 +952,7 @@ describe "TreeView", ->
afterEach ->
fsUtils.remove(ignoreFile) if fsUtils.exists(ignoreFile)
fsUtils.remove(newFile) if fsUtils.exists(newFile)
fsUtils.write modifiedFile, originalFileContent
fsUtils.writeSync modifiedFile, originalFileContent
describe "when a file is modified", ->
it "adds a custom style", ->

View File

@@ -6,7 +6,7 @@ describe "Whitespace", ->
beforeEach ->
path = "/tmp/atom-whitespace.txt"
fsUtils.write(path, "")
fsUtils.writeSync(path, "")
window.rootView = new RootView
rootView.open(path)

View File

@@ -120,11 +120,11 @@ module.exports =
path.split("/")
# Open, write, flush, and close a file, writing the given content.
write: (path, content) ->
writeSync: (path, content) ->
mkdirp.sync(Path.dirname(path))
fs.writeFileSync(path, content)
writeAsync: (path, content, callback) ->
write: (path, content, callback) ->
mkdirp Path.dirname(path), (error) ->
if error?
callback?(error)