diff --git a/spec/file-spec.coffee b/spec/file-spec.coffee index f00354e..bad6b09 100644 --- a/spec/file-spec.coffee +++ b/spec/file-spec.coffee @@ -506,3 +506,10 @@ describe 'File', -> readHandler.callCount > 0 runs -> expect(readHandler.argsForCall[0][0]).toBe(null) + + describe 'writeSync()', -> + it 'emits did-change event', -> + file.onDidChange writeHandler = jasmine.createSpy('write handler') + file.writeSync('ok') + waitsFor 'write handler', -> + writeHandler.callCount > 0 diff --git a/src/file.coffee b/src/file.coffee index ee81003..b9bf58f 100644 --- a/src/file.coffee +++ b/src/file.coffee @@ -322,6 +322,8 @@ class File @writeFileSync(@getPath(), text) @cachedContents = text @setDigest(text) + @emit 'contents-changed' if Grim.includeDeprecatedAPIs + @emitter.emit 'did-change' @subscribeToNativeChangeEvents() if not previouslyExisted and @hasSubscriptions() undefined