Set config schema entirely in the snapshot

This commit is contained in:
Antonio Scandurra
2017-03-08 15:28:19 +01:00
parent f5a19a6904
commit 05eb737a94
3 changed files with 16 additions and 15 deletions

View File

@@ -210,18 +210,12 @@ class AtomEnvironment extends Model
@views.initialize()
@config.initialize({@configDirPath, resourcePath})
@projectHomeSchema = {
type: 'object',
properties: {
projectHome: {
type: 'string',
default: path.join(fs.getHomeDirectory(), 'github'),
description: 'The directory where projects are assumed to be located. Packages created using the Package Generator will be stored here by default.'
}
}
ConfigSchema.projectHome = {
type: 'string',
default: path.join(fs.getHomeDirectory(), 'github'),
description: 'The directory where projects are assumed to be located. Packages created using the Package Generator will be stored here by default.'
}
@config.setSchema('core', @projectHomeSchema)
@config.initialize({@configDirPath, resourcePath, projectHomeSchema: ConfigSchema.projectHome})
@keymaps.configDirPath = @configDirPath
@keymaps.resourcePath = resourcePath
@@ -322,7 +316,6 @@ class AtomEnvironment extends Model
@config.clear()
@config.setSchema null, {type: 'object', properties: _.clone(ConfigSchema)}
@config.setSchema('core', @projectHomeSchema)
@keymaps.clear()
@keymaps.loadBundledKeymaps()

View File

@@ -401,11 +401,13 @@ class Config
constructor: ({@notificationManager, @enablePersistence}={}) ->
@clear()
initialize: ({@configDirPath, @resourcePath}) ->
initialize: ({@configDirPath, @resourcePath, projectHomeSchema}) ->
if @enablePersistence?
@configFilePath = fs.resolve(@configDirPath, 'config', ['json', 'cson'])
@configFilePath ?= path.join(@configDirPath, 'config.cson')
@schema.properties.core.properties.projectHome = projectHomeSchema
clear: ->
@emitter = new Emitter
@schema =

View File

@@ -17,6 +17,7 @@ url = require 'url'
_ = require 'underscore-plus'
FindParentDir = null
Resolve = null
ConfigSchema = require '../config-schema'
LocationSuffixRegExp = /(:\d+)(:\d+)?$/
@@ -69,8 +70,13 @@ class AtomApplication
@windows = []
@config = new Config({enablePersistence: true})
@config.initialize({configDirPath: process.env.ATOM_HOME, @resourcePath})
@config.setSchema null, {type: 'object', properties: _.clone(require('../config-schema'))}
@config.setSchema null, {type: 'object', properties: _.clone(ConfigSchema)}
ConfigSchema.projectHome = {
type: 'string',
default: path.join(fs.getHomeDirectory(), 'github'),
description: 'The directory where projects are assumed to be located. Packages created using the Package Generator will be stored here by default.'
}
@config.initialize({configDirPath: process.env.ATOM_HOME, @resourcePath, projectHomeSchema: ConfigSchema.projectHome})
@config.load()
@fileRecoveryService = new FileRecoveryService(path.join(process.env.ATOM_HOME, "recovery"))
@storageFolder = new StorageFolder(process.env.ATOM_HOME)