mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Rename writeSync to writeFileSync
This commit is contained in:
@@ -15,7 +15,7 @@ describe "install(commandPath, callback)", ->
|
||||
fs.removeSync(directory) if fs.existsSync(directory)
|
||||
|
||||
it "symlinks the command and makes it executable", ->
|
||||
fs.writeSync(commandPath, 'test')
|
||||
fs.writeFileSync(commandPath, 'test')
|
||||
expect(fs.isFileSync(commandPath)).toBeTruthy()
|
||||
expect(fs.isExecutableSync(commandPath)).toBeFalsy()
|
||||
expect(fs.isFileSync(destinationPath)).toBeFalsy()
|
||||
|
||||
@@ -208,7 +208,7 @@ describe "Config", ->
|
||||
|
||||
describe "when the config file contains valid cson", ->
|
||||
beforeEach ->
|
||||
fs.writeSync(config.configFilePath, "foo: bar: 'baz'")
|
||||
fs.writeFileSync(config.configFilePath, "foo: bar: 'baz'")
|
||||
config.loadUserConfig()
|
||||
|
||||
it "updates the config data based on the file contents", ->
|
||||
@@ -217,7 +217,7 @@ describe "Config", ->
|
||||
describe "when the config file contains invalid cson", ->
|
||||
beforeEach ->
|
||||
spyOn(console, 'error')
|
||||
fs.writeSync(config.configFilePath, "{{{{{")
|
||||
fs.writeFileSync(config.configFilePath, "{{{{{")
|
||||
|
||||
it "logs an error to the console and does not overwrite the config file on a subsequent save", ->
|
||||
config.loadUserConfig()
|
||||
@@ -239,7 +239,7 @@ describe "Config", ->
|
||||
config.configDirPath = dotAtomPath
|
||||
config.configFilePath = path.join(config.configDirPath, "config.cson")
|
||||
expect(fs.existsSync(config.configDirPath)).toBeFalsy()
|
||||
fs.writeSync(config.configFilePath, "foo: bar: 'baz'")
|
||||
fs.writeFileSync(config.configFilePath, "foo: bar: 'baz'")
|
||||
config.loadUserConfig()
|
||||
config.observeUserConfig()
|
||||
updatedHandler = jasmine.createSpy("updatedHandler")
|
||||
@@ -251,7 +251,7 @@ describe "Config", ->
|
||||
|
||||
describe "when the config file changes to contain valid cson", ->
|
||||
it "updates the config data", ->
|
||||
fs.writeSync(config.configFilePath, "foo: { bar: 'quux', baz: 'bar'}")
|
||||
fs.writeFileSync(config.configFilePath, "foo: { bar: 'quux', baz: 'bar'}")
|
||||
waitsFor 'update event', -> updatedHandler.callCount > 0
|
||||
runs ->
|
||||
expect(config.get('foo.bar')).toBe 'quux'
|
||||
@@ -260,7 +260,7 @@ describe "Config", ->
|
||||
describe "when the config file changes to contain invalid cson", ->
|
||||
beforeEach ->
|
||||
spyOn(console, 'error')
|
||||
fs.writeSync(config.configFilePath, "}}}")
|
||||
fs.writeFileSync(config.configFilePath, "}}}")
|
||||
waitsFor "error to be logged", -> console.error.callCount > 0
|
||||
|
||||
it "logs a warning and does not update config data", ->
|
||||
@@ -271,7 +271,7 @@ describe "Config", ->
|
||||
|
||||
describe "when the config file subsequently changes again to contain valid cson", ->
|
||||
beforeEach ->
|
||||
fs.writeSync(config.configFilePath, "foo: bar: 'baz'")
|
||||
fs.writeFileSync(config.configFilePath, "foo: bar: 'baz'")
|
||||
waitsFor 'update event', -> updatedHandler.callCount > 0
|
||||
|
||||
it "updates the config data and resumes saving", ->
|
||||
|
||||
@@ -27,7 +27,7 @@ describe "Directory", ->
|
||||
runs ->
|
||||
changeHandler = jasmine.createSpy('changeHandler')
|
||||
directory.on 'contents-changed', changeHandler
|
||||
fs.writeSync(temporaryFilePath, '')
|
||||
fs.writeFileSync(temporaryFilePath, '')
|
||||
|
||||
waitsFor "first change", -> changeHandler.callCount > 0
|
||||
|
||||
@@ -53,7 +53,7 @@ describe "Directory", ->
|
||||
runs ->
|
||||
changeHandler = jasmine.createSpy('changeHandler')
|
||||
directory.on 'contents-changed', changeHandler
|
||||
fs.writeSync(temporaryFilePath, '')
|
||||
fs.writeFileSync(temporaryFilePath, '')
|
||||
|
||||
waitsFor "change event", -> changeHandler.callCount > 0
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ describe "Editor", ->
|
||||
describe "when the activeEditSession's file is modified on disk", ->
|
||||
it "triggers an alert", ->
|
||||
filePath = path.join(temp.dir, 'atom-changed-file.txt')
|
||||
fs.writeSync(filePath, "")
|
||||
fs.writeFileSync(filePath, "")
|
||||
editSession = project.openSync(filePath)
|
||||
editor.edit(editSession)
|
||||
editor.insertText("now the buffer is modified")
|
||||
@@ -98,7 +98,7 @@ describe "Editor", ->
|
||||
|
||||
spyOn(atom, "confirm")
|
||||
|
||||
fs.writeSync(filePath, "a file change")
|
||||
fs.writeFileSync(filePath, "a file change")
|
||||
|
||||
waitsFor "file to trigger contents-changed event", ->
|
||||
fileChangeHandler.callCount > 0
|
||||
@@ -153,7 +153,7 @@ describe "Editor", ->
|
||||
|
||||
it "triggers alert if edit session's buffer goes into conflict with changes on disk", ->
|
||||
filePath = path.join(temp.dir, 'atom-changed-file.txt')
|
||||
fs.writeSync(filePath, "")
|
||||
fs.writeFileSync(filePath, "")
|
||||
tempEditSession = project.openSync(filePath)
|
||||
editor.edit(tempEditSession)
|
||||
tempEditSession.insertText("a buffer change")
|
||||
@@ -162,7 +162,7 @@ describe "Editor", ->
|
||||
|
||||
contentsConflictedHandler = jasmine.createSpy("contentsConflictedHandler")
|
||||
tempEditSession.on 'contents-conflicted', contentsConflictedHandler
|
||||
fs.writeSync(filePath, "a file change")
|
||||
fs.writeFileSync(filePath, "a file change")
|
||||
waitsFor ->
|
||||
contentsConflictedHandler.callCount > 0
|
||||
|
||||
@@ -249,7 +249,7 @@ describe "Editor", ->
|
||||
|
||||
beforeEach ->
|
||||
filePath = path.join(temp.dir, 'something.txt')
|
||||
fs.writeSync(filePath, filePath)
|
||||
fs.writeFileSync(filePath, filePath)
|
||||
|
||||
afterEach ->
|
||||
fs.removeSync(filePath) if fs.existsSync(filePath)
|
||||
@@ -2183,7 +2183,7 @@ describe "Editor", ->
|
||||
editor.edit(project.openSync(filePath))
|
||||
|
||||
afterEach ->
|
||||
fs.writeSync(filePath, originalPathText)
|
||||
fs.writeFileSync(filePath, originalPathText)
|
||||
|
||||
it "restores the contents of the editor to the HEAD revision", ->
|
||||
editor.setText('')
|
||||
@@ -2307,7 +2307,7 @@ describe "Editor", ->
|
||||
beforeEach ->
|
||||
tmpdir = fs.absolute(temp.dir)
|
||||
filePath = path.join(tmpdir, "grammar-change.txt")
|
||||
fs.writeSync(filePath, "var i;")
|
||||
fs.writeFileSync(filePath, "var i;")
|
||||
|
||||
afterEach ->
|
||||
fs.removeSync(filePath) if fs.existsSync(filePath)
|
||||
@@ -2661,9 +2661,9 @@ describe "Editor", ->
|
||||
statePath = path.join(temp.dir, 'state')
|
||||
expect(atom.showSaveDialog).toHaveBeenCalled()
|
||||
saveDialogCallback(statePath)
|
||||
expect(fs.writeSync).toHaveBeenCalled()
|
||||
expect(fs.writeSync.argsForCall[0][0]).toBe statePath
|
||||
expect(typeof fs.writeSync.argsForCall[0][1]).toBe 'string'
|
||||
expect(fs.writeFileSync).toHaveBeenCalled()
|
||||
expect(fs.writeFileSync.argsForCall[0][0]).toBe statePath
|
||||
expect(typeof fs.writeFileSync.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", ->
|
||||
|
||||
@@ -7,7 +7,7 @@ describe 'File', ->
|
||||
beforeEach ->
|
||||
filePath = path.join(__dirname, 'fixtures', 'atom-file-test.txt') # Don't put in /tmp because /tmp symlinks to /private/tmp and screws up the rename test
|
||||
fs.removeSync(filePath) if fs.existsSync(filePath)
|
||||
fs.writeSync(filePath, "this is old!")
|
||||
fs.writeFileSync(filePath, "this is old!")
|
||||
file = new File(filePath)
|
||||
|
||||
afterEach ->
|
||||
@@ -18,7 +18,7 @@ describe 'File', ->
|
||||
describe "when the contents of the file change", ->
|
||||
it "triggers 'contents-changed' event handlers", ->
|
||||
file.on 'contents-changed', changeHandler = jasmine.createSpy('changeHandler')
|
||||
fs.writeSync(file.getPath(), "this is new!")
|
||||
fs.writeFileSync(file.getPath(), "this is new!")
|
||||
|
||||
waitsFor "change event", ->
|
||||
changeHandler.callCount > 0
|
||||
@@ -32,14 +32,14 @@ describe 'File', ->
|
||||
changeHandler = null
|
||||
changeHandler = jasmine.createSpy('changeHandler')
|
||||
file.on 'contents-changed', changeHandler
|
||||
fs.writeSync(file.getPath(), "this is new!")
|
||||
fs.writeFileSync(file.getPath(), "this is new!")
|
||||
|
||||
waitsFor "change event", ->
|
||||
changeHandler.callCount > 0
|
||||
|
||||
runs ->
|
||||
changeHandler.reset()
|
||||
fs.writeSync(file.getPath(), "this is newer!")
|
||||
fs.writeFileSync(file.getPath(), "this is newer!")
|
||||
|
||||
waitsFor "second change event", ->
|
||||
changeHandler.callCount > 0
|
||||
@@ -95,7 +95,7 @@ describe 'File', ->
|
||||
|
||||
runs ->
|
||||
expect(changeHandler).not.toHaveBeenCalled()
|
||||
fs.writeSync(file.getPath(), "this is new!")
|
||||
fs.writeFileSync(file.getPath(), "this is new!")
|
||||
|
||||
waitsFor "change event", ->
|
||||
changeHandler.callCount > 0
|
||||
@@ -117,7 +117,7 @@ describe 'File', ->
|
||||
expect(changeHandler).not.toHaveBeenCalled()
|
||||
waits 20
|
||||
runs ->
|
||||
fs.writeSync(filePath, "HE HAS RISEN!")
|
||||
fs.writeFileSync(filePath, "HE HAS RISEN!")
|
||||
expect(changeHandler).not.toHaveBeenCalled()
|
||||
|
||||
waitsFor "resurrection change event", ->
|
||||
@@ -125,7 +125,7 @@ describe 'File', ->
|
||||
|
||||
runs ->
|
||||
expect(removeHandler).not.toHaveBeenCalled()
|
||||
fs.writeSync(filePath, "Hallelujah!")
|
||||
fs.writeFileSync(filePath, "Hallelujah!")
|
||||
changeHandler.reset()
|
||||
|
||||
waitsFor "post-resurrection change event", ->
|
||||
|
||||
@@ -50,7 +50,7 @@ describe "Git", ->
|
||||
originalPathText = fs.readFileSync(filePath, 'utf8')
|
||||
|
||||
afterEach ->
|
||||
fs.writeSync(filePath, originalPathText)
|
||||
fs.writeFileSync(filePath, originalPathText)
|
||||
fs.removeSync(newPath) if fs.existsSync(newPath)
|
||||
|
||||
describe "when the path is unstaged", ->
|
||||
@@ -58,7 +58,7 @@ describe "Git", ->
|
||||
expect(repo.isPathModified(filePath)).toBeFalsy()
|
||||
|
||||
it "returns true if the path is modified", ->
|
||||
fs.writeSync(filePath, "change")
|
||||
fs.writeFileSync(filePath, "change")
|
||||
expect(repo.isPathModified(filePath)).toBeTruthy()
|
||||
|
||||
it "returns true if the path is deleted", ->
|
||||
@@ -75,7 +75,7 @@ describe "Git", ->
|
||||
repo = new Git(path.join(__dirname, 'fixtures', 'git', 'working-dir'))
|
||||
filePath = require.resolve('./fixtures/git/working-dir/file.txt')
|
||||
newPath = path.join(__dirname, 'fixtures', 'git', 'working-dir', 'new-path.txt')
|
||||
fs.writeSync(newPath, "i'm new here")
|
||||
fs.writeFileSync(newPath, "i'm new here")
|
||||
|
||||
afterEach ->
|
||||
fs.removeSync(newPath) if fs.existsSync(newPath)
|
||||
@@ -98,30 +98,30 @@ describe "Git", ->
|
||||
originalPath2Text = fs.readFileSync(path2, 'utf8')
|
||||
|
||||
afterEach ->
|
||||
fs.writeSync(path1, originalPath1Text)
|
||||
fs.writeSync(path2, originalPath2Text)
|
||||
fs.writeFileSync(path1, originalPath1Text)
|
||||
fs.writeFileSync(path2, originalPath2Text)
|
||||
|
||||
it "no longer reports a path as modified after checkout", ->
|
||||
expect(repo.isPathModified(path1)).toBeFalsy()
|
||||
fs.writeSync(path1, '')
|
||||
fs.writeFileSync(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", ->
|
||||
fs.writeSync(path1, '')
|
||||
fs.writeFileSync(path1, '')
|
||||
expect(repo.checkoutHead(path1)).toBeTruthy()
|
||||
expect(fs.readFileSync(path1, 'utf8')).toBe(originalPath1Text)
|
||||
|
||||
it "only restores the path specified", ->
|
||||
fs.writeSync(path2, 'path 2 is edited')
|
||||
fs.writeFileSync(path2, 'path 2 is edited')
|
||||
expect(repo.isPathModified(path2)).toBeTruthy()
|
||||
expect(repo.checkoutHead(path1)).toBeTruthy()
|
||||
expect(fs.readFileSync(path2, 'utf8')).toBe('path 2 is edited')
|
||||
expect(repo.isPathModified(path2)).toBeTruthy()
|
||||
|
||||
it "fires a status-changed event if the checkout completes successfully", ->
|
||||
fs.writeSync(path1, '')
|
||||
fs.writeFileSync(path1, '')
|
||||
repo.getPathStatus(path1)
|
||||
statusHandler = jasmine.createSpy('statusHandler')
|
||||
repo.on 'status-changed', statusHandler
|
||||
@@ -147,11 +147,11 @@ describe "Git", ->
|
||||
originalPathText = fs.readFileSync(filePath, 'utf8')
|
||||
|
||||
afterEach ->
|
||||
fs.writeSync(filePath, originalPathText)
|
||||
fs.writeFileSync(filePath, originalPathText)
|
||||
|
||||
it "returns the number of lines added and deleted", ->
|
||||
expect(repo.getDiffStats(filePath)).toEqual {added: 0, deleted: 0}
|
||||
fs.writeSync(filePath, "#{originalPathText} edited line")
|
||||
fs.writeFileSync(filePath, "#{originalPathText} edited line")
|
||||
expect(repo.getDiffStats(filePath)).toEqual {added: 1, deleted: 1}
|
||||
|
||||
describe ".getPathStatus(path)", ->
|
||||
@@ -163,17 +163,17 @@ describe "Git", ->
|
||||
originalPathText = fs.readFileSync(filePath, 'utf8')
|
||||
|
||||
afterEach ->
|
||||
fs.writeSync(filePath, originalPathText)
|
||||
fs.writeFileSync(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
|
||||
fs.writeSync(filePath, '')
|
||||
fs.writeFileSync(filePath, '')
|
||||
status = repo.getPathStatus(filePath)
|
||||
expect(statusHandler.callCount).toBe 1
|
||||
expect(statusHandler.argsForCall[0][0..1]).toEqual [filePath, status]
|
||||
|
||||
fs.writeSync(filePath, 'abc')
|
||||
fs.writeFileSync(filePath, 'abc')
|
||||
status = repo.getPathStatus(filePath)
|
||||
expect(statusHandler.callCount).toBe 1
|
||||
|
||||
@@ -186,14 +186,14 @@ describe "Git", ->
|
||||
originalModifiedPathText = fs.readFileSync(modifiedPath, 'utf8')
|
||||
newPath = project.resolve('git/working-dir/untracked.txt')
|
||||
cleanPath = project.resolve('git/working-dir/other.txt')
|
||||
fs.writeSync(newPath, '')
|
||||
fs.writeFileSync(newPath, '')
|
||||
|
||||
afterEach ->
|
||||
fs.writeSync(modifiedPath, originalModifiedPathText)
|
||||
fs.writeFileSync(modifiedPath, originalModifiedPathText)
|
||||
fs.removeSync(newPath) if fs.existsSync(newPath)
|
||||
|
||||
it "returns status information for all new and modified files", ->
|
||||
fs.writeSync(modifiedPath, 'making this path modified')
|
||||
fs.writeFileSync(modifiedPath, 'making this path modified')
|
||||
statusHandler = jasmine.createSpy('statusHandler')
|
||||
repo.on 'statuses-changed', statusHandler
|
||||
repo.refreshStatus()
|
||||
@@ -215,7 +215,7 @@ describe "Git", ->
|
||||
originalContent = editSession.getText()
|
||||
|
||||
afterEach ->
|
||||
fs.writeSync(editSession.getPath(), originalContent)
|
||||
fs.writeFileSync(editSession.getPath(), originalContent)
|
||||
|
||||
it "emits a status-changed event when a buffer is saved", ->
|
||||
editSession.insertNewline()
|
||||
@@ -227,7 +227,7 @@ describe "Git", ->
|
||||
expect(statusHandler).toHaveBeenCalledWith editSession.getPath(), 256
|
||||
|
||||
it "emits a status-changed event when a buffer is reloaded", ->
|
||||
fs.writeSync(editSession.getPath(), 'changed')
|
||||
fs.writeFileSync(editSession.getPath(), 'changed')
|
||||
|
||||
statusHandler = jasmine.createSpy('statusHandler')
|
||||
project.getRepo().on 'status-changed', statusHandler
|
||||
@@ -238,7 +238,7 @@ describe "Git", ->
|
||||
expect(statusHandler.callCount).toBe 1
|
||||
|
||||
it "emits a status-changed event when a buffer's path changes", ->
|
||||
fs.writeSync(editSession.getPath(), 'changed')
|
||||
fs.writeFileSync(editSession.getPath(), 'changed')
|
||||
|
||||
statusHandler = jasmine.createSpy('statusHandler')
|
||||
project.getRepo().on 'status-changed', statusHandler
|
||||
@@ -252,7 +252,7 @@ describe "Git", ->
|
||||
[originalContent, buffer, project2] = []
|
||||
|
||||
afterEach ->
|
||||
fs.writeSync(buffer.getPath(), originalContent)
|
||||
fs.writeFileSync(buffer.getPath(), originalContent)
|
||||
project2?.destroy()
|
||||
|
||||
it "subscribes to all the serialized buffers in the project", ->
|
||||
|
||||
@@ -365,7 +365,7 @@ describe "Project", ->
|
||||
runs ->
|
||||
fs.rename(path.join(projectPath, 'git.git'), path.join(projectPath, '.git'))
|
||||
ignoredPath = path.join(projectPath, 'ignored.txt')
|
||||
fs.writeSync(ignoredPath, 'this match should not be included')
|
||||
fs.writeFileSync(ignoredPath, 'this match should not be included')
|
||||
|
||||
afterEach ->
|
||||
fs.removeSync(projectPath) if fs.existsSync(projectPath)
|
||||
@@ -402,7 +402,7 @@ describe "Project", ->
|
||||
it "includes files and folders that begin with a '.'", ->
|
||||
projectPath = temp.mkdirSync()
|
||||
filePath = path.join(projectPath, '.text')
|
||||
fs.writeSync(filePath, 'match this')
|
||||
fs.writeFileSync(filePath, 'match this')
|
||||
project.setPath(projectPath)
|
||||
paths = []
|
||||
matches = []
|
||||
|
||||
@@ -52,7 +52,7 @@ describe 'TextBuffer', ->
|
||||
beforeEach ->
|
||||
filePath = path.join(__dirname, "fixtures", "atom-manipulate-me")
|
||||
newPath = "#{filePath}-i-moved"
|
||||
fs.writeSync(filePath, "")
|
||||
fs.writeFileSync(filePath, "")
|
||||
bufferToChange = project.bufferForPathSync(filePath)
|
||||
eventHandler = jasmine.createSpy('eventHandler')
|
||||
bufferToChange.on 'path-changed', eventHandler
|
||||
@@ -84,7 +84,7 @@ describe 'TextBuffer', ->
|
||||
beforeEach ->
|
||||
buffer.release()
|
||||
filePath = temp.openSync('atom').path
|
||||
fs.writeSync(filePath, "first")
|
||||
fs.writeFileSync(filePath, "first")
|
||||
buffer = project.bufferForPathSync(filePath).retain()
|
||||
|
||||
afterEach ->
|
||||
@@ -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
|
||||
fs.writeSync(filePath, "second")
|
||||
fs.writeFileSync(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")
|
||||
fs.writeSync(filePath, "second")
|
||||
fs.writeFileSync(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')
|
||||
fs.writeSync(filePath, "a disk change")
|
||||
fs.writeFileSync(filePath, "a disk change")
|
||||
buffer.on 'contents-conflicted', handler
|
||||
|
||||
expect(handler.callCount).toBe 0
|
||||
@@ -155,7 +155,7 @@ describe 'TextBuffer', ->
|
||||
|
||||
beforeEach ->
|
||||
filePath = path.join(temp.dir, 'atom-file-to-delete.txt')
|
||||
fs.writeSync(filePath, 'delete me')
|
||||
fs.writeFileSync(filePath, 'delete me')
|
||||
bufferToDelete = project.bufferForPathSync(filePath)
|
||||
filePath = bufferToDelete.getPath() # symlinks may have been converted
|
||||
|
||||
@@ -180,7 +180,7 @@ describe 'TextBuffer', ->
|
||||
expect(fs.existsSync(bufferToDelete.getPath())).toBeTruthy()
|
||||
expect(bufferToDelete.isInConflict()).toBeFalsy()
|
||||
|
||||
fs.writeSync(filePath, 'moo')
|
||||
fs.writeFileSync(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 = path.join(temp.dir, 'atom-tmp-file')
|
||||
fs.writeSync(filePath, 'delete me')
|
||||
fs.writeFileSync(filePath, 'delete me')
|
||||
buffer = project.bufferForPathSync(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 = path.join(temp.dir, 'atom-tmp-file')
|
||||
fs.writeSync(filePath, '')
|
||||
fs.writeFileSync(filePath, '')
|
||||
buffer.release()
|
||||
buffer = project.bufferForPathSync(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 = path.join(temp.dir, 'atom-tmp-file')
|
||||
fs.writeSync(filePath, '')
|
||||
fs.writeFileSync(filePath, '')
|
||||
buffer.release()
|
||||
buffer = project.bufferForPathSync(filePath)
|
||||
modifiedHandler = jasmine.createSpy("modifiedHandler")
|
||||
@@ -465,7 +465,7 @@ describe 'TextBuffer', ->
|
||||
|
||||
beforeEach ->
|
||||
filePath = path.join(temp.dir, 'temp.txt')
|
||||
fs.writeSync(filePath, "")
|
||||
fs.writeFileSync(filePath, "")
|
||||
saveBuffer = project.bufferForPathSync(filePath)
|
||||
saveBuffer.setText("blah")
|
||||
|
||||
@@ -474,7 +474,7 @@ describe 'TextBuffer', ->
|
||||
saveBuffer.save()
|
||||
expect(fs.readFileSync(filePath, 'utf8')).toEqual 'Buffer contents!'
|
||||
|
||||
it "fires will-be-saved and saved events around the call to fs.writeSync", ->
|
||||
it "fires will-be-saved and saved events around the call to fs.writeFileSync", ->
|
||||
events = []
|
||||
beforeSave1 = -> events.push('beforeSave1')
|
||||
beforeSave2 = -> events.push('beforeSave2')
|
||||
@@ -483,12 +483,12 @@ describe 'TextBuffer', ->
|
||||
|
||||
saveBuffer.on 'will-be-saved', beforeSave1
|
||||
saveBuffer.on 'will-be-saved', beforeSave2
|
||||
spyOn(fs, 'writeSync').andCallFake -> events.push 'fs.writeSync'
|
||||
spyOn(fs, 'writeSync').andCallFake -> events.push 'fs.writeFileSync'
|
||||
saveBuffer.on 'saved', afterSave1
|
||||
saveBuffer.on 'saved', afterSave2
|
||||
|
||||
saveBuffer.save()
|
||||
expect(events).toEqual ['beforeSave1', 'beforeSave2', 'fs.writeSync', 'afterSave1', 'afterSave2']
|
||||
expect(events).toEqual ['beforeSave1', 'beforeSave2', 'fs.writeFileSync', 'afterSave1', 'afterSave2']
|
||||
|
||||
it "fires will-reload and reloaded events when reloaded", ->
|
||||
events = []
|
||||
@@ -537,7 +537,7 @@ describe 'TextBuffer', ->
|
||||
it "stops listening to events on previous path and begins listening to events on new path", ->
|
||||
originalPath = path.join(temp.dir, 'original.txt')
|
||||
newPath = path.join(temp.dir, 'new.txt')
|
||||
fs.writeSync(originalPath, "")
|
||||
fs.writeFileSync(originalPath, "")
|
||||
|
||||
saveAsBuffer = project.bufferForPathSync(originalPath).retain()
|
||||
changeHandler = jasmine.createSpy('changeHandler')
|
||||
@@ -545,11 +545,11 @@ describe 'TextBuffer', ->
|
||||
saveAsBuffer.saveAs(newPath)
|
||||
expect(changeHandler).not.toHaveBeenCalled()
|
||||
|
||||
fs.writeSync(originalPath, "should not trigger buffer event")
|
||||
fs.writeFileSync(originalPath, "should not trigger buffer event")
|
||||
waits 20
|
||||
runs ->
|
||||
expect(changeHandler).not.toHaveBeenCalled()
|
||||
fs.writeSync(newPath, "should trigger buffer event")
|
||||
fs.writeFileSync(newPath, "should trigger buffer event")
|
||||
|
||||
waitsFor ->
|
||||
changeHandler.callCount > 0
|
||||
@@ -560,7 +560,7 @@ describe 'TextBuffer', ->
|
||||
beforeEach ->
|
||||
filePath = path.join(__dirname, "fixtures", "atom-manipulate-me")
|
||||
newPath = "#{filePath}-i-moved"
|
||||
fs.writeSync(filePath, "")
|
||||
fs.writeFileSync(filePath, "")
|
||||
bufferToChange = project.bufferForPathSync(filePath)
|
||||
eventHandler = jasmine.createSpy('eventHandler')
|
||||
bufferToChange.on 'path-changed', eventHandler
|
||||
@@ -954,13 +954,13 @@ describe 'TextBuffer', ->
|
||||
buffer.release()
|
||||
|
||||
filePath = temp.openSync('atom').path
|
||||
fs.writeSync(filePath, "words")
|
||||
fs.writeFileSync(filePath, "words")
|
||||
{buffer} = project.openSync(filePath)
|
||||
buffer.setText("BUFFER CHANGE")
|
||||
|
||||
state = buffer.serialize()
|
||||
expect(state.getObject('text')).toBe 'BUFFER CHANGE'
|
||||
fs.writeSync(filePath, "DISK CHANGE")
|
||||
fs.writeFileSync(filePath, "DISK CHANGE")
|
||||
|
||||
buffer2 = deserialize(state, {project})
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ fs.makeTree = fs.makeTreeSync
|
||||
fs.move = fs.moveSync
|
||||
fs.read = (filePath) -> fs.readFileSync(filePath, 'utf8')
|
||||
fs.remove = fs.removeSync
|
||||
fs.writeSync = fs.writeFileSync
|
||||
|
||||
fs = require 'fs-plus'
|
||||
{$} = require './space-pen-extensions'
|
||||
|
||||
@@ -1824,7 +1824,7 @@ class Editor extends View
|
||||
|
||||
saveDebugSnapshot: ->
|
||||
atom.showSaveDialog (path) =>
|
||||
fs.writeSync(path, @getDebugSnapshot()) if path
|
||||
fs.writeFileSync(path, @getDebugSnapshot()) if path
|
||||
|
||||
getDebugSnapshot: ->
|
||||
[
|
||||
|
||||
@@ -57,7 +57,7 @@ class File
|
||||
write: (text) ->
|
||||
previouslyExisted = @exists()
|
||||
@cachedContents = text
|
||||
fs.writeSync(@getPath(), text)
|
||||
fs.writeFileSync(@getPath(), text)
|
||||
@subscribeToNativeChangeEvents() if not previouslyExisted and @subscriptionCount() > 0
|
||||
|
||||
# Private: Deprecated
|
||||
|
||||
Reference in New Issue
Block a user