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

@@ -207,7 +207,7 @@ describe "Config", ->
describe "when the config file contains valid cson", ->
beforeEach ->
fsUtils.write(config.configFilePath, "foo: bar: 'baz'")
fsUtils.writeSync(config.configFilePath, "foo: bar: 'baz'")
config.loadUserConfig()
it "updates the config data based on the file contents", ->
@@ -216,7 +216,7 @@ describe "Config", ->
describe "when the config file contains invalid cson", ->
beforeEach ->
spyOn(console, 'error')
fsUtils.write(config.configFilePath, "{{{{{")
fsUtils.writeSync(config.configFilePath, "{{{{{")
it "logs an error to the console and does not overwrite the config file on a subsequent save", ->
config.loadUserConfig()
@@ -231,7 +231,7 @@ describe "Config", ->
config.configDirPath = '/tmp/dot-atom-dir'
config.configFilePath = path.join(config.configDirPath, "config.cson")
expect(fsUtils.exists(config.configDirPath)).toBeFalsy()
fsUtils.write(config.configFilePath, "foo: bar: 'baz'")
fsUtils.writeSync(config.configFilePath, "foo: bar: 'baz'")
config.loadUserConfig()
config.observeUserConfig()
updatedHandler = jasmine.createSpy("updatedHandler")
@@ -243,7 +243,7 @@ describe "Config", ->
describe "when the config file changes to contain valid cson", ->
it "updates the config data", ->
fsUtils.write(config.configFilePath, "foo: { bar: 'quux', baz: 'bar'}")
fsUtils.writeSync(config.configFilePath, "foo: { bar: 'quux', baz: 'bar'}")
waitsFor 'update event', -> updatedHandler.callCount > 0
runs ->
expect(config.get('foo.bar')).toBe 'quux'
@@ -252,7 +252,7 @@ describe "Config", ->
describe "when the config file changes to contain invalid cson", ->
beforeEach ->
spyOn(console, 'error')
fsUtils.write(config.configFilePath, "}}}")
fsUtils.writeSync(config.configFilePath, "}}}")
waitsFor "error to be logged", -> console.error.callCount > 0
it "logs a warning and does not update config data", ->
@@ -263,7 +263,7 @@ describe "Config", ->
describe "when the config file subsequently changes again to contain valid cson", ->
beforeEach ->
fsUtils.write(config.configFilePath, "foo: bar: 'baz'")
fsUtils.writeSync(config.configFilePath, "foo: bar: 'baz'")
waitsFor 'update event', -> updatedHandler.callCount > 0
it "updates the config data and resumes saving", ->

View File

@@ -27,7 +27,7 @@ describe "Directory", ->
runs ->
changeHandler = jasmine.createSpy('changeHandler')
directory.on 'contents-changed', changeHandler
fsUtils.write(temporaryFilePath, '')
fsUtils.writeSync(temporaryFilePath, '')
waitsFor "first change", -> changeHandler.callCount > 0
@@ -53,7 +53,7 @@ describe "Directory", ->
runs ->
changeHandler = jasmine.createSpy('changeHandler')
directory.on 'contents-changed', changeHandler
fsUtils.write(temporaryFilePath, '')
fsUtils.writeSync(temporaryFilePath, '')
waitsFor "change event", -> changeHandler.callCount > 0

View File

@@ -85,7 +85,7 @@ describe "Editor", ->
describe "when the activeEditSession's file is modified on disk", ->
it "triggers an alert", ->
filePath = "/tmp/atom-changed-file.txt"
fsUtils.write(filePath, "")
fsUtils.writeSync(filePath, "")
editSession = project.open(filePath)
editor.edit(editSession)
editor.insertText("now the buffer is modified")
@@ -95,7 +95,7 @@ describe "Editor", ->
spyOn(atom, "confirm")
fsUtils.write(filePath, "a file change")
fsUtils.writeSync(filePath, "a file change")
waitsFor "file to trigger contents-changed event", ->
fileChangeHandler.callCount > 0
@@ -150,7 +150,7 @@ describe "Editor", ->
it "triggers alert if edit session's buffer goes into conflict with changes on disk", ->
filePath = "/tmp/atom-changed-file.txt"
fsUtils.write(filePath, "")
fsUtils.writeSync(filePath, "")
tempEditSession = project.open(filePath)
editor.edit(tempEditSession)
tempEditSession.insertText("a buffer change")
@@ -159,7 +159,7 @@ describe "Editor", ->
contentsConflictedHandler = jasmine.createSpy("contentsConflictedHandler")
tempEditSession.on 'contents-conflicted', contentsConflictedHandler
fsUtils.write(filePath, "a file change")
fsUtils.writeSync(filePath, "a file change")
waitsFor ->
contentsConflictedHandler.callCount > 0
@@ -246,7 +246,7 @@ describe "Editor", ->
beforeEach ->
filePath = "/tmp/something.txt"
fsUtils.write(filePath, filePath)
fsUtils.writeSync(filePath, filePath)
afterEach ->
fsUtils.remove(filePath) if fsUtils.exists(filePath)
@@ -2084,7 +2084,7 @@ describe "Editor", ->
editor.edit(project.open(filePath))
afterEach ->
fsUtils.write(filePath, originalPathText)
fsUtils.writeSync(filePath, originalPathText)
it "restores the contents of the editor to the HEAD revision", ->
editor.setText('')
@@ -2196,7 +2196,7 @@ describe "Editor", ->
beforeEach ->
filePath = path.join(fsUtils.absolute("/tmp"), "grammar-change.txt")
fsUtils.write(filePath, "var i;")
fsUtils.writeSync(filePath, "var i;")
afterEach ->
fsUtils.remove(filePath) if fsUtils.exists(filePath)
@@ -2543,15 +2543,15 @@ describe "Editor", ->
it "saves the state of the rendered lines, the display buffer, and the buffer to a file of the user's choosing", ->
saveDialogCallback = null
spyOn(atom, 'showSaveDialog').andCallFake (callback) -> saveDialogCallback = callback
spyOn(fsUtils, 'write')
spyOn(fsUtils, 'writeSync')
editor.trigger 'editor:save-debug-snapshot'
expect(atom.showSaveDialog).toHaveBeenCalled()
saveDialogCallback('/tmp/state')
expect(fsUtils.write).toHaveBeenCalled()
expect(fsUtils.write.argsForCall[0][0]).toBe '/tmp/state'
expect(typeof fsUtils.write.argsForCall[0][1]).toBe 'string'
expect(fsUtils.writeSync).toHaveBeenCalled()
expect(fsUtils.writeSync.argsForCall[0][0]).toBe '/tmp/state'
expect(typeof fsUtils.writeSync.argsForCall[0][1]).toBe 'string'
describe "when the escape key is pressed on the editor", ->
it "clears multiple selections if there are any, and otherwise allows other bindings to be handled", ->

View File

@@ -8,7 +8,7 @@ describe 'File', ->
beforeEach ->
filePath = path.join(fsUtils.resolveOnLoadPath('fixtures'), "atom-file-test.txt") # Don't put in /tmp because /tmp symlinks to /private/tmp and screws up the rename test
fsUtils.remove(filePath) if fsUtils.exists(filePath)
fsUtils.write(filePath, "this is old!")
fsUtils.writeSync(filePath, "this is old!")
file = new File(filePath)
file.read()
@@ -21,14 +21,14 @@ describe 'File', ->
changeHandler = null
changeHandler = jasmine.createSpy('changeHandler')
file.on 'contents-changed', changeHandler
fsUtils.write(file.getPath(), "this is new!")
fsUtils.writeSync(file.getPath(), "this is new!")
waitsFor "change event", ->
changeHandler.callCount > 0
runs ->
changeHandler.reset()
fsUtils.write(file.getPath(), "this is newer!")
fsUtils.writeSync(file.getPath(), "this is newer!")
waitsFor "second change event", ->
changeHandler.callCount > 0
@@ -84,7 +84,7 @@ describe 'File', ->
runs ->
expect(changeHandler).not.toHaveBeenCalled()
fsUtils.write(file.getPath(), "this is new!")
fsUtils.writeSync(file.getPath(), "this is new!")
waitsFor "change event", ->
changeHandler.callCount > 0
@@ -106,7 +106,7 @@ describe 'File', ->
expect(changeHandler).not.toHaveBeenCalled()
waits 20
runs ->
fsUtils.write(filePath, "HE HAS RISEN!")
fsUtils.writeSync(filePath, "HE HAS RISEN!")
expect(changeHandler).not.toHaveBeenCalled()
waitsFor "resurrection change event", ->
@@ -114,7 +114,7 @@ describe 'File', ->
runs ->
expect(removeHandler).not.toHaveBeenCalled()
fsUtils.write(filePath, "Hallelujah!")
fsUtils.writeSync(filePath, "Hallelujah!")
changeHandler.reset()
waitsFor "post-resurrection change event", ->

View File

@@ -58,7 +58,7 @@ describe "Git", ->
originalPathText = fsUtils.read(filePath)
afterEach ->
fsUtils.write(filePath, originalPathText)
fsUtils.writeSync(filePath, originalPathText)
fsUtils.remove(newPath) if fsUtils.exists(newPath)
describe "when the path is unstaged", ->
@@ -66,7 +66,7 @@ describe "Git", ->
expect(repo.isPathModified(filePath)).toBeFalsy()
it "returns true if the path is modified", ->
fsUtils.write(filePath, "change")
fsUtils.writeSync(filePath, "change")
expect(repo.isPathModified(filePath)).toBeTruthy()
it "returns true if the path is deleted", ->
@@ -83,7 +83,7 @@ describe "Git", ->
repo = new Git(fsUtils.resolveOnLoadPath('fixtures/git/working-dir'))
filePath = fsUtils.resolveOnLoadPath('fixtures/git/working-dir/file.txt')
newPath = path.join(fsUtils.resolveOnLoadPath('fixtures/git/working-dir'), 'new-path.txt')
fsUtils.write(newPath, "i'm new here")
fsUtils.writeSync(newPath, "i'm new here")
afterEach ->
fsUtils.remove(newPath) if fsUtils.exists(newPath)
@@ -106,30 +106,30 @@ describe "Git", ->
originalPath2Text = fsUtils.read(path2)
afterEach ->
fsUtils.write(path1, originalPath1Text)
fsUtils.write(path2, originalPath2Text)
fsUtils.writeSync(path1, originalPath1Text)
fsUtils.writeSync(path2, originalPath2Text)
it "no longer reports a path as modified after checkout", ->
expect(repo.isPathModified(path1)).toBeFalsy()
fsUtils.write(path1, '')
fsUtils.writeSync(path1, '')
expect(repo.isPathModified(path1)).toBeTruthy()
expect(repo.checkoutHead(path1)).toBeTruthy()
expect(repo.isPathModified(path1)).toBeFalsy()
it "restores the contents of the path to the original text", ->
fsUtils.write(path1, '')
fsUtils.writeSync(path1, '')
expect(repo.checkoutHead(path1)).toBeTruthy()
expect(fsUtils.read(path1)).toBe(originalPath1Text)
it "only restores the path specified", ->
fsUtils.write(path2, 'path 2 is edited')
fsUtils.writeSync(path2, 'path 2 is edited')
expect(repo.isPathModified(path2)).toBeTruthy()
expect(repo.checkoutHead(path1)).toBeTruthy()
expect(fsUtils.read(path2)).toBe('path 2 is edited')
expect(repo.isPathModified(path2)).toBeTruthy()
it "fires a status-changed event if the checkout completes successfully", ->
fsUtils.write(path1, '')
fsUtils.writeSync(path1, '')
repo.getPathStatus(path1)
statusHandler = jasmine.createSpy('statusHandler')
repo.on 'status-changed', statusHandler
@@ -155,11 +155,11 @@ describe "Git", ->
originalPathText = fsUtils.read(filePath)
afterEach ->
fsUtils.write(filePath, originalPathText)
fsUtils.writeSync(filePath, originalPathText)
it "returns the number of lines added and deleted", ->
expect(repo.getDiffStats(filePath)).toEqual {added: 0, deleted: 0}
fsUtils.write(filePath, "#{originalPathText} edited line")
fsUtils.writeSync(filePath, "#{originalPathText} edited line")
expect(repo.getDiffStats(filePath)).toEqual {added: 1, deleted: 1}
describe ".getPathStatus(path)", ->
@@ -171,17 +171,17 @@ describe "Git", ->
originalPathText = fsUtils.read(filePath)
afterEach ->
fsUtils.write(filePath, originalPathText)
fsUtils.writeSync(filePath, originalPathText)
it "trigger a status-changed event when the new status differs from the last cached one", ->
statusHandler = jasmine.createSpy("statusHandler")
repo.on 'status-changed', statusHandler
fsUtils.write(filePath, '')
fsUtils.writeSync(filePath, '')
status = repo.getPathStatus(filePath)
expect(statusHandler.callCount).toBe 1
expect(statusHandler.argsForCall[0][0..1]).toEqual [filePath, status]
fsUtils.write(filePath, 'abc')
fsUtils.writeSync(filePath, 'abc')
status = repo.getPathStatus(filePath)
expect(statusHandler.callCount).toBe 1
@@ -194,14 +194,14 @@ describe "Git", ->
originalModifiedPathText = fsUtils.read(modifiedPath)
newPath = project.resolve('git/working-dir/untracked.txt')
cleanPath = project.resolve('git/working-dir/other.txt')
fsUtils.write(newPath, '')
fsUtils.writeSync(newPath, '')
afterEach ->
fsUtils.write(modifiedPath, originalModifiedPathText)
fsUtils.writeSync(modifiedPath, originalModifiedPathText)
fsUtils.remove(newPath) if fsUtils.exists(newPath)
it "returns status information for all new and modified files", ->
fsUtils.write(modifiedPath, 'making this path modified')
fsUtils.writeSync(modifiedPath, 'making this path modified')
statusHandler = jasmine.createSpy('statusHandler')
repo.on 'statuses-changed', statusHandler
repo.refreshStatus()
@@ -216,7 +216,7 @@ describe "Git", ->
expect(repo.isStatusModified(statuses[modifiedPath])).toBeTruthy()
it "only starts a single task at a time and schedules a restart if one is already running", =>
fsUtils.write(modifiedPath, 'making this path modified')
fsUtils.writeSync(modifiedPath, 'making this path modified')
statusHandler = jasmine.createSpy('statusHandler')
repo.on 'statuses-changed', statusHandler

View File

@@ -173,7 +173,7 @@ describe "Project", ->
beforeEach ->
ignoredFile = path.join(fsUtils.resolveOnLoadPath('fixtures/dir'), 'ignored.txt')
fsUtils.write(ignoredFile, "")
fsUtils.writeSync(ignoredFile, "")
afterEach ->
fsUtils.remove(ignoredFile)
@@ -192,7 +192,7 @@ describe "Project", ->
beforeEach ->
ignoredFile = path.join(fsUtils.resolveOnLoadPath('fixtures/dir'), 'ignored/ignored.txt')
fsUtils.write(ignoredFile, "")
fsUtils.writeSync(ignoredFile, "")
afterEach ->
fsUtils.remove(ignoredFile)
@@ -282,7 +282,7 @@ describe "Project", ->
beforeEach ->
projectPath = fsUtils.resolveOnLoadPath('fixtures/git/working-dir')
ignoredPath = path.join(projectPath, 'ignored.txt')
fsUtils.write(ignoredPath, 'this match should not be included')
fsUtils.writeSync(ignoredPath, 'this match should not be included')
afterEach ->
fsUtils.remove(ignoredPath) if fsUtils.exists(ignoredPath)
@@ -304,7 +304,7 @@ describe "Project", ->
it "includes files and folders that begin with a '.'", ->
projectPath = '/tmp/atom-tests/folder-with-dot-file'
filePath = path.join(projectPath, '.text')
fsUtils.write(filePath, 'match this')
fsUtils.writeSync(filePath, 'match this')
project.setPath(projectPath)
paths = []
matches = []
@@ -321,7 +321,7 @@ describe "Project", ->
it "excludes values in core.ignoredNames", ->
projectPath = '/tmp/atom-tests/folder-with-dot-git/.git'
filePath = path.join(projectPath, 'test.txt')
fsUtils.write(filePath, 'match this')
fsUtils.writeSync(filePath, 'match this')
project.setPath(projectPath)
paths = []
matches = []

View File

@@ -51,7 +51,7 @@ describe 'TextBuffer', ->
beforeEach ->
filePath = path.join(fsUtils.resolveOnLoadPath("fixtures"), "atom-manipulate-me")
newPath = "#{filePath}-i-moved"
fsUtils.write(filePath, "")
fsUtils.writeSync(filePath, "")
bufferToChange = project.bufferForPath(filePath)
eventHandler = jasmine.createSpy('eventHandler')
bufferToChange.on 'path-changed', eventHandler
@@ -82,7 +82,7 @@ describe 'TextBuffer', ->
beforeEach ->
filePath = "/tmp/tmp.txt"
fsUtils.write(filePath, "first")
fsUtils.writeSync(filePath, "first")
buffer.release()
buffer = project.bufferForPath(filePath).retain()
@@ -105,7 +105,7 @@ describe 'TextBuffer', ->
it "changes the memory contents of the buffer to match the new disk contents and triggers a 'changed' event", ->
changeHandler = jasmine.createSpy('changeHandler')
buffer.on 'changed', changeHandler
fsUtils.write(filePath, "second")
fsUtils.writeSync(filePath, "second")
expect(changeHandler.callCount).toBe 0
waitsFor "file to trigger change event", ->
@@ -125,7 +125,7 @@ describe 'TextBuffer', ->
buffer.file.on 'contents-changed', fileChangeHandler
buffer.insert([0, 0], "a change")
fsUtils.write(filePath, "second")
fsUtils.writeSync(filePath, "second")
expect(fileChangeHandler.callCount).toBe 0
waitsFor "file to trigger 'contents-changed' event", ->
@@ -140,7 +140,7 @@ describe 'TextBuffer', ->
buffer.insert([0, 0], "a second change")
handler = jasmine.createSpy('fileChange')
fsUtils.write(filePath, "second")
fsUtils.writeSync(filePath, "second")
buffer.on 'contents-conflicted', handler
expect(handler.callCount).toBe 0
@@ -155,7 +155,7 @@ describe 'TextBuffer', ->
beforeEach ->
filePath = "/tmp/atom-file-to-delete.txt"
fsUtils.write(filePath, 'delete me')
fsUtils.writeSync(filePath, 'delete me')
bufferToDelete = project.bufferForPath(filePath)
filePath = bufferToDelete.getPath() # symlinks may have been converted
@@ -180,7 +180,7 @@ describe 'TextBuffer', ->
expect(bufferToDelete.fileExists()).toBeTruthy()
expect(bufferToDelete.isInConflict()).toBeFalsy()
fsUtils.write(filePath, 'moo')
fsUtils.writeSync(filePath, 'moo')
changeHandler = jasmine.createSpy('changeHandler')
bufferToDelete.on 'changed', changeHandler
@@ -213,7 +213,7 @@ describe 'TextBuffer', ->
it "reports the modified status changing to true after the underlying file is deleted", ->
buffer.release()
filePath = "/tmp/atom-tmp-file"
fsUtils.write(filePath, 'delete me')
fsUtils.writeSync(filePath, 'delete me')
buffer = project.bufferForPath(filePath)
modifiedHandler = jasmine.createSpy("modifiedHandler")
buffer.on 'modified-status-changed', modifiedHandler
@@ -225,7 +225,7 @@ describe 'TextBuffer', ->
it "reports the modified status changing to false after a modified buffer is saved", ->
filePath = "/tmp/atom-tmp-file"
fsUtils.write(filePath, '')
fsUtils.writeSync(filePath, '')
buffer.release()
buffer = project.bufferForPath(filePath)
modifiedHandler = jasmine.createSpy("modifiedHandler")
@@ -249,7 +249,7 @@ describe 'TextBuffer', ->
it "reports the modified status changing to false after a modified buffer is reloaded", ->
filePath = "/tmp/atom-tmp-file"
fsUtils.write(filePath, '')
fsUtils.writeSync(filePath, '')
buffer.release()
buffer = project.bufferForPath(filePath)
modifiedHandler = jasmine.createSpy("modifiedHandler")
@@ -452,7 +452,7 @@ describe 'TextBuffer', ->
beforeEach ->
filePath = '/tmp/temp.txt'
fsUtils.write(filePath, "")
fsUtils.writeSync(filePath, "")
saveBuffer = project.bufferForPath(filePath)
saveBuffer.setText("blah")
@@ -461,7 +461,7 @@ describe 'TextBuffer', ->
saveBuffer.save()
expect(fsUtils.read(filePath)).toEqual 'Buffer contents!'
it "fires will-be-saved and saved events around the call to fsUtils.write", ->
it "fires will-be-saved and saved events around the call to fsUtils.writeSync", ->
events = []
beforeSave1 = -> events.push('beforeSave1')
beforeSave2 = -> events.push('beforeSave2')
@@ -470,12 +470,12 @@ describe 'TextBuffer', ->
saveBuffer.on 'will-be-saved', beforeSave1
saveBuffer.on 'will-be-saved', beforeSave2
spyOn(fsUtils, 'write').andCallFake -> events.push 'fsUtils.write'
spyOn(fsUtils, 'writeSync').andCallFake -> events.push 'fsUtils.writeSync'
saveBuffer.on 'saved', afterSave1
saveBuffer.on 'saved', afterSave2
saveBuffer.save()
expect(events).toEqual ['beforeSave1', 'beforeSave2', 'fsUtils.write', 'afterSave1', 'afterSave2']
expect(events).toEqual ['beforeSave1', 'beforeSave2', 'fsUtils.writeSync', 'afterSave1', 'afterSave2']
it "fires will-reload and reloaded events when reloaded", ->
events = []
@@ -524,7 +524,7 @@ describe 'TextBuffer', ->
it "stops listening to events on previous path and begins listening to events on new path", ->
originalPath = "/tmp/original.txt"
newPath = "/tmp/new.txt"
fsUtils.write(originalPath, "")
fsUtils.writeSync(originalPath, "")
saveAsBuffer = project.bufferForPath(originalPath).retain()
changeHandler = jasmine.createSpy('changeHandler')
@@ -532,11 +532,11 @@ describe 'TextBuffer', ->
saveAsBuffer.saveAs(newPath)
expect(changeHandler).not.toHaveBeenCalled()
fsUtils.write(originalPath, "should not trigger buffer event")
fsUtils.writeSync(originalPath, "should not trigger buffer event")
waits 20
runs ->
expect(changeHandler).not.toHaveBeenCalled()
fsUtils.write(newPath, "should trigger buffer event")
fsUtils.writeSync(newPath, "should trigger buffer event")
waitsFor ->
changeHandler.callCount > 0

View File

@@ -14,7 +14,7 @@ describe "install(commandPath, callback)", ->
fsUtils.remove(directory) if fsUtils.exists(directory)
it "symlinks the command and makes it executable", ->
fsUtils.write(commandPath, 'test')
fsUtils.writeSync(commandPath, 'test')
expect(fsUtils.isFileSync(commandPath)).toBeTruthy()
expect(fsUtils.isExecutableSync(commandPath)).toBeFalsy()
expect(fsUtils.isFileSync(destinationPath)).toBeFalsy()

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)