💉 directory dependencies into Config

This commit is contained in:
Kevin Sawicki
2013-10-07 15:28:00 -07:00
parent 9db3f9b5d9
commit 0033c9659f
3 changed files with 24 additions and 22 deletions

View File

@@ -51,7 +51,9 @@ beforeEach ->
bindingSetsByFirstKeystrokeToRestore = _.clone(keymap.bindingSetsByFirstKeystroke)
# reset config before each spec; don't load or save from/to `config.json`
config = new Config()
config = new Config
resourcePath: window.resourcePath
configDirPath: atom.getConfigDirPath()
config.packageDirPaths.unshift(fixturePackagesPath)
spyOn(config, 'load')
spyOn(config, 'save')

View File

@@ -28,6 +28,7 @@ class Atom
@unsubscribe()
{devMode, resourcePath} = atom.getLoadSettings()
configDirPath = @getConfigDirPath()
Config = require './config'
Keymap = require './keymap'
@@ -37,20 +38,21 @@ class Atom
ThemeManager = require './theme-manager'
ContextMenuManager = require './context-menu-manager'
@themes = new ThemeManager()
@contextMenu = new ContextMenuManager(devMode)
@config = new Config()
@pasteboard = new Pasteboard()
@keymap = new Keymap()
@syntax = deserialize(@getWindowState('syntax')) ? new Syntax()
@packages = new PackageManager({devMode, resourcePath, configDirPath: @config.getDirectoryPath()})
@subscribe @packages, 'loaded', => @watchThemes()
@packages = new PackageManager({devMode, configDirPath, resourcePath})
#TODO Remove once packages have been updated to not touch atom.packageStates directly
@__defineGetter__ 'packageStates', => @packages.packageStates
@__defineSetter__ 'packageStates', (packageStates) => @packages.packageStates = packageStates
@subscribe @packages, 'loaded', => @watchThemes()
@themes = new ThemeManager()
@contextMenu = new ContextMenuManager(devMode)
@config = new Config({configDirPath, resourcePath})
@pasteboard = new Pasteboard()
@keymap = new Keymap()
@syntax = deserialize(@getWindowState('syntax')) ? new Syntax()
getCurrentWindow: ->
remote.getCurrentWindow()
@@ -215,6 +217,10 @@ class Atom
getHomeDirPath: ->
app.getHomeDir()
# Public: Get the directory path to Atom's configuration area.
getConfigDirPath: ->
@configDirPath ?= fsUtils.absolute('~/.atom')
getWindowStatePath: ->
switch @windowMode
when 'spec'

View File

@@ -7,8 +7,6 @@ path = require 'path'
async = require 'async'
pathWatcher = require 'pathwatcher'
configDirPath = fsUtils.absolute("~/.atom")
# Public: Used to access all of Atom's configuration details.
#
# A global instance of this class is available to all plugins which can be
@@ -35,14 +33,13 @@ class Config
configFileHasErrors: null
# Private: Created during initialization, available as `global.config`
constructor: ->
@configDirPath = configDirPath
@bundledKeymapsDirPath = path.join(resourcePath, "keymaps")
@nodeModulesDirPath = path.join(resourcePath, "node_modules")
constructor: ({@configDirPath, @resourcePath}={}) ->
@bundledKeymapsDirPath = path.join(@resourcePath, "keymaps")
@nodeModulesDirPath = path.join(@resourcePath, "node_modules")
@bundledPackageDirPaths = [@nodeModulesDirPath]
@lessSearchPaths = [
path.join(resourcePath, 'static', 'variables')
path.join(resourcePath, 'static')
path.join(@resourcePath, 'static', 'variables')
path.join(@resourcePath, 'static')
]
@packageDirPaths = [path.join(configDirPath, "packages")]
if atom.getLoadSettings().devMode
@@ -67,7 +64,7 @@ class Config
fsUtils.copy(sourcePath, destinationPath, callback)
queue.drain = done
templateConfigDirPath = fsUtils.resolve(window.resourcePath, 'dot-atom')
templateConfigDirPath = fsUtils.resolve(@resourcePath, 'dot-atom')
onConfigDirFile = (sourcePath) =>
relativePath = sourcePath.substring(templateConfigDirPath.length + 1)
destinationPath = path.join(@configDirPath, relativePath)
@@ -117,9 +114,6 @@ class Config
_.extend hash, defaults
@update()
# Public: Get the path to this config's directory.
getDirectoryPath: -> @configDirPath
# Public: Returns a new {Object} containing all of settings and defaults.
getSettings: ->
_.deepExtend(@settings, @defaultSettings)