Add global config object. Config#load loads user's atom.coffee.

This commit is contained in:
Nathan Sobo
2012-12-12 11:40:09 -08:00
parent ab96129ef6
commit 9c31ab3a79
5 changed files with 17 additions and 12 deletions

7
src/app/config.coffee Normal file
View File

@@ -0,0 +1,7 @@
module.exports =
class Config
load: ->
try
require atom.configFilePath if fs.exists(atom.configFilePath)
catch error
console.error "Failed to load `#{atom.configFilePath}`", error.stack, error

View File

@@ -36,6 +36,8 @@ class RootView extends View
initialize: (pathToOpen, { @extensionStates, suppressOpen } = {}) ->
window.rootView = this
config.load()
TextMateTheme.activate('IR_Black')
@invisibles =
@@ -47,7 +49,6 @@ class RootView extends View
@extensions = {}
@project = new Project(pathToOpen)
@handleEvents()
@loadUserConfiguration()
if pathToOpen
@open(pathToOpen) if fs.isFile(pathToOpen) and not suppressOpen
@@ -263,11 +264,5 @@ class RootView extends View
getInvisibles: -> @invisibles
loadUserConfiguration: ->
try
require atom.configFilePath if fs.exists(atom.configFilePath)
catch error
console.error "Failed to load `#{atom.configFilePath}`", error.stack, error
saveAll: ->
editor.save() for editor in @getEditors()

View File

@@ -8,6 +8,7 @@ fs = require 'fs'
_ = require 'underscore'
$ = require 'jquery'
{CoffeeScript} = require 'coffee-script'
Config = require 'config'
RootView = require 'root-view'
Pasteboard = require 'pasteboard'
require 'jquery-extensions'
@@ -26,6 +27,7 @@ windowAdditions =
TextMateTheme.loadAll()
@setUpKeymap()
@pasteboard = new Pasteboard
@config = new Config
$(window).on 'core:close', => @close()
# This method is intended only to be run when starting a normal application