Don't write config defaults out to config.json

This commit is contained in:
Nathan Sobo
2013-01-04 17:06:03 -07:00
parent dec3ab7873
commit d509093076
2 changed files with 30 additions and 6 deletions

View File

@@ -22,12 +22,14 @@ class Config
configDirPath: configDirPath
themeDirPaths: [userThemesDirPath, bundledThemesDirPath]
packageDirPaths: [userPackagesDirPath, bundledVendorPackagesDirPath, bundledPackagesDirPath]
defaultSettings: null
settings: null
constructor: ->
@settings =
@defaultSettings =
core: _.clone(require('root-view').configDefaults)
editor: _.clone(require('editor').configDefaults)
@settings = {}
load: ->
@loadUserConfig()
@@ -41,7 +43,8 @@ class Config
_.extend(@settings, userConfig)
get: (keyPath) ->
_.valueForKeyPath(@settings, keyPath)
_.valueForKeyPath(@settings, keyPath) ?
_.valueForKeyPath(@defaultSettings, keyPath)
set: (keyPath, value) ->
keys = keyPath.split('.')
@@ -57,12 +60,12 @@ class Config
setDefaults: (keyPath, defaults) ->
keys = keyPath.split('.')
hash = @settings
hash = @defaultSettings
for key in keys
hash[key] ?= {}
hash = hash[key]
_.defaults hash, defaults
_.extend hash, defaults
@update()
observe: (keyPath, callback) ->