Assign config in Atom environment constructor

This commit is contained in:
Nathan Sobo
2015-09-28 13:21:50 -06:00
parent 43c959fdeb
commit 88d80b1c97
3 changed files with 27 additions and 20 deletions

View File

@@ -152,6 +152,8 @@ class Atom extends Model
# Call .loadOrCreate instead
constructor: (@state) ->
{@mode} = @state
{resourcePath} = @getLoadSettings()
configDirPath = @getConfigDirPath()
@emitter = new Emitter
@disposables = new CompositeDisposable
@@ -163,6 +165,12 @@ class Atom extends Model
NotificationManager = require './notification-manager'
@notifications = new NotificationManager
Config = require './config'
@config = new Config({configDirPath, resourcePath, notificationManager: @notifications})
reset: ->
@config.reset()
# Sets up the basic services that should be available in all modes
# (both spec and application).
#
@@ -196,7 +204,6 @@ class Atom extends Model
@loadTime = null
Config = require './config'
KeymapManager = require './keymap-extensions'
ViewRegistry = require './view-registry'
CommandRegistry = require './command-registry'
@@ -220,7 +227,6 @@ class Atom extends Model
# Make react.js faster
process.env.NODE_ENV ?= 'production' unless devMode
@config = new Config({configDirPath, resourcePath})
@keymaps = new KeymapManager({configDirPath, resourcePath})
@keymaps.subscribeToFileReadFailure()
@tooltips = new TooltipManager

View File

@@ -331,7 +331,12 @@ class Config
value
# Created during initialization, available as `atom.config`
constructor: ({@configDirPath, @resourcePath}={}) ->
constructor: ({@configDirPath, @resourcePath, @notificationManager}={}) ->
@configFilePath = fs.resolve(@configDirPath, 'config', ['json', 'cson'])
@configFilePath ?= path.join(@configDirPath, 'config.cson')
@reset()
reset: ->
@emitter = new Emitter
@schema =
type: 'object'
@@ -340,11 +345,8 @@ class Config
@settings = {}
@scopedSettingsStore = new ScopedPropertyStore
@configFileHasErrors = false
@configFilePath = fs.resolve(@configDirPath, 'config', ['json', 'cson'])
@configFilePath ?= path.join(@configDirPath, 'config.cson')
@transactDepth = 0
@savePending = false
@requestLoad = _.debounce(@loadUserConfig, 100)
@requestSave = =>
@savePending = true
@@ -779,7 +781,7 @@ class Config
@watchSubscription = null
notifyFailure: (errorMessage, detail) ->
atom.notifications.addError(errorMessage, {detail, dismissable: true})
@notificationManager.addError(errorMessage, {detail, dismissable: true})
save: ->
allSettings = {'*': @settings}