Create an empty ~/.atom/config.cson when missing

Closes #614
This commit is contained in:
Kevin Sawicki
2013-07-05 09:17:44 -07:00
parent 0448ba5ceb
commit 651bbaa3ce
3 changed files with 22 additions and 10 deletions

View File

@@ -66,16 +66,19 @@ class Config
@observeUserConfig()
loadUserConfig: ->
if fsUtils.exists(@configFilePath)
try
userConfig = CSON.readFileSync(@configFilePath)
_.extend(@settings, userConfig)
@configFileHasErrors = false
@trigger 'updated'
catch e
@configFileHasErrors = true
console.error "Failed to load user config '#{@configFilePath}'", e.message
console.error e.stack
if !fsUtils.exists(@configFilePath)
fsUtils.makeTree(path.dirname(@configFilePath))
CSON.writeFileSync(@configFilePath, {})
try
userConfig = CSON.readFileSync(@configFilePath)
_.extend(@settings, userConfig)
@configFileHasErrors = false
@trigger 'updated'
catch e
@configFileHasErrors = true
console.error "Failed to load user config '#{@configFilePath}'", e.message
console.error e.stack
observeUserConfig: ->
@watchSubscription ?= pathWatcher.watch @configFilePath, (eventType) =>