From dc44d11a2cee008a0b1ff4ed6784420e125cd4fc Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 14 Oct 2015 20:05:06 -0600 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20load/save=20config=20if=20enabl?= =?UTF-8?q?ePersistence=20option=20is=20false?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/config-spec.coffee | 4 ++++ spec/jasmine-test-runner.coffee | 6 +++++- src/atom-environment.coffee | 4 ++-- src/config.coffee | 6 +++--- src/initialize-application-window.coffee | 7 ++++++- 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/spec/config-spec.coffee b/spec/config-spec.coffee index 7329ac6c9..bb9ab89a8 100644 --- a/spec/config-spec.coffee +++ b/spec/config-spec.coffee @@ -11,8 +11,12 @@ describe "Config", -> spyOn(atom.config, "save") dotAtomPath = temp.path('dot-atom-dir') atom.config.configDirPath = dotAtomPath + atom.config.enablePersistence = true atom.config.configFilePath = path.join(atom.config.configDirPath, "atom.config.cson") + afterEach -> + atom.config.enablePersistence = false + describe ".get(keyPath, {scope, sources, excludeSources})", -> it "allows a key path's value to be read", -> expect(atom.config.set("foo.bar.baz", 42)).toBe true diff --git a/spec/jasmine-test-runner.coffee b/spec/jasmine-test-runner.coffee index 04b875ac8..8d1eeac85 100644 --- a/spec/jasmine-test-runner.coffee +++ b/spec/jasmine-test-runner.coffee @@ -18,7 +18,11 @@ module.exports = ({logFile, headless, testPaths, buildAtomEnvironment}) -> applicationDelegate = new ApplicationDelegate() applicationDelegate.setRepresentedFilename = -> applicationDelegate.setWindowDocumentEdited = -> - window.atom = buildAtomEnvironment({applicationDelegate, window, document}) + window.atom = buildAtomEnvironment({ + applicationDelegate, window, document, + configDirPath: process.env.ATOM_HOME + enablePersistence: false + }) require './spec-helper' disableFocusMethods() if process.env.JANKY_SHA1 or process.env.CI diff --git a/src/atom-environment.coffee b/src/atom-environment.coffee index ed56831bf..acccef475 100644 --- a/src/atom-environment.coffee +++ b/src/atom-environment.coffee @@ -116,7 +116,7 @@ class AtomEnvironment extends Model # Call .loadOrCreate instead constructor: (params={}) -> - {@applicationDelegate, @window, @document, configDirPath} = params + {@applicationDelegate, @window, @document, configDirPath, @enablePersistence} = params @state = {version: @constructor.version} @@ -133,7 +133,7 @@ class AtomEnvironment extends Model @notifications = new NotificationManager - @config = new Config({configDirPath, resourcePath, notificationManager: @notifications}) + @config = new Config({configDirPath, resourcePath, notificationManager: @notifications, @enablePersistence}) @setConfigSchema() @keymaps = new KeymapManager({configDirPath, resourcePath, notificationManager: @notifications}) diff --git a/src/config.coffee b/src/config.coffee index 3a616c9a7..cb09a8d83 100644 --- a/src/config.coffee +++ b/src/config.coffee @@ -334,8 +334,8 @@ class Config value # Created during initialization, available as `atom.config` - constructor: ({@configDirPath, @resourcePath, @notificationManager}={}) -> - if @configDirPath? + constructor: ({@configDirPath, @resourcePath, @notificationManager, @enablePersistence}={}) -> + if @enablePersistence? @configFilePath = fs.resolve(@configDirPath, 'config', ['json', 'cson']) @configFilePath ?= path.join(@configDirPath, 'config.cson') @clear() @@ -360,7 +360,7 @@ class Config @save() debouncedSave = _.debounce(save, 100) - shouldNotAccessFileSystem: -> not @configDirPath? + shouldNotAccessFileSystem: -> not @enablePersistence ### Section: Config Subscription diff --git a/src/initialize-application-window.coffee b/src/initialize-application-window.coffee index 71b1f3b15..acf50bc5d 100644 --- a/src/initialize-application-window.coffee +++ b/src/initialize-application-window.coffee @@ -16,7 +16,12 @@ process.env.NODE_ENV ?= 'production' unless devMode AtomEnvironment = require './atom-environment' ApplicationDelegate = require './application-delegate' -window.atom = new AtomEnvironment({applicationDelegate: new ApplicationDelegate, window, document, configDirPath: process.env.ATOM_HOME}) +window.atom = new AtomEnvironment({ + window, document, + applicationDelegate: new ApplicationDelegate, + configDirPath: process.env.ATOM_HOME + enablePersistence: true +}) atom.displayWindow() atom.loadStateSync()