mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Add global config object. Config#load loads user's atom.coffee.
This commit is contained in:
@@ -3,7 +3,7 @@ $ = require 'jquery'
|
||||
_ = require 'underscore'
|
||||
Keymap = require 'keymap'
|
||||
Point = require 'point'
|
||||
RootView = require 'root-view'
|
||||
Config = require 'config'
|
||||
Project = require 'project'
|
||||
TextMateBundle = require 'text-mate-bundle'
|
||||
TextMateTheme = require 'text-mate-theme'
|
||||
@@ -11,7 +11,9 @@ TextMateTheme = require 'text-mate-theme'
|
||||
require 'window'
|
||||
requireStylesheet "jasmine.css"
|
||||
|
||||
RootView.prototype.loadUserConfiguration = ->
|
||||
beforeEach ->
|
||||
# don't load user configuration
|
||||
spyOn(config, 'load')
|
||||
|
||||
keymap = new Keymap
|
||||
keymap.bindDefaultKeys()
|
||||
|
||||
@@ -20,6 +20,8 @@ beforeEach ->
|
||||
window.fixturesProject = new Project(require.resolve('fixtures'))
|
||||
window.resetTimeouts()
|
||||
|
||||
# don't load user configuration
|
||||
spyOn(config, 'load')
|
||||
# make editor display updates synchronous
|
||||
spyOn(Editor.prototype, 'requestDisplayUpdate').andCallFake -> @updateDisplay()
|
||||
spyOn(RootView.prototype, 'updateWindowTitle').andCallFake ->
|
||||
@@ -42,9 +44,6 @@ window.keymap.bindKeys '*', 'meta-w': 'close'
|
||||
$(document).on 'close', -> window.close()
|
||||
$('html,body').css('overflow', 'auto')
|
||||
|
||||
# Don't load user configuration in specs, because it's variable
|
||||
RootView.prototype.loadUserConfiguration = ->
|
||||
|
||||
ensureNoPathSubscriptions = ->
|
||||
watchedPaths = $native.getWatchedPaths()
|
||||
$native.unwatchAllPaths()
|
||||
|
||||
7
src/app/config.coffee
Normal file
7
src/app/config.coffee
Normal 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
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user