Show notification on config save failures
Esse commit está contido em:
@@ -666,6 +666,23 @@ describe "Config", ->
|
|||||||
foo:
|
foo:
|
||||||
bar: 'coffee'
|
bar: 'coffee'
|
||||||
|
|
||||||
|
describe "when an error is thrown writing the file to disk", ->
|
||||||
|
addErrorHandler = null
|
||||||
|
beforeEach ->
|
||||||
|
atom.notifications.onDidAddNotification addErrorHandler = jasmine.createSpy()
|
||||||
|
|
||||||
|
it "creates a notification", ->
|
||||||
|
jasmine.unspy CSON, 'writeFileSync'
|
||||||
|
spyOn(CSON, 'writeFileSync').andCallFake ->
|
||||||
|
error = new Error()
|
||||||
|
error.code = 'EPERM'
|
||||||
|
error.path = atom.config.getUserConfigPath()
|
||||||
|
throw error
|
||||||
|
|
||||||
|
save = -> atom.config.save()
|
||||||
|
expect(save).not.toThrow()
|
||||||
|
expect(addErrorHandler.callCount).toBe 1
|
||||||
|
|
||||||
describe ".loadUserConfig()", ->
|
describe ".loadUserConfig()", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
expect(fs.existsSync(atom.config.configDirPath)).toBeFalsy()
|
expect(fs.existsSync(atom.config.configDirPath)).toBeFalsy()
|
||||||
|
|||||||
+6
-1
@@ -868,7 +868,12 @@ class Config
|
|||||||
save: ->
|
save: ->
|
||||||
allSettings = {'*': @settings}
|
allSettings = {'*': @settings}
|
||||||
allSettings = _.extend allSettings, @scopedSettingsStore.propertiesForSource(@getUserConfigPath())
|
allSettings = _.extend allSettings, @scopedSettingsStore.propertiesForSource(@getUserConfigPath())
|
||||||
CSON.writeFileSync(@configFilePath, allSettings)
|
try
|
||||||
|
CSON.writeFileSync(@configFilePath, allSettings)
|
||||||
|
catch error
|
||||||
|
message = "Failed to save `#{path.basename(@configFilePath)}`"
|
||||||
|
detail = error.message
|
||||||
|
@notifyFailure(message, detail)
|
||||||
|
|
||||||
###
|
###
|
||||||
Section: Private methods managing global settings
|
Section: Private methods managing global settings
|
||||||
|
|||||||
Referência em uma Nova Issue
Bloquear um usuário