Don’t load/save config if enablePersistence option is false

This commit is contained in:
Nathan Sobo
2015-10-14 20:05:06 -06:00
parent 9df40b4f4e
commit dc44d11a2c
5 changed files with 20 additions and 7 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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})

View File

@@ -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

View File

@@ -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()