mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Use Atom's standard config file to set custom color profile
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
const fs = require('fs')
|
||||
|
||||
module.exports =
|
||||
class ElectronSwitchStore {
|
||||
constructor ({filePath}) {
|
||||
this.store = this.load(filePath)
|
||||
}
|
||||
|
||||
entries () {
|
||||
return this.store.entries()
|
||||
}
|
||||
|
||||
// Private
|
||||
load (filePath) {
|
||||
const map = new Map()
|
||||
|
||||
if (fs.existsSync(filePath)) {
|
||||
const lines = fs.readFileSync(filePath, 'utf8').split(/\r?\n/g)
|
||||
for (const line of lines) {
|
||||
const indexOfNameValueSeparator = line.indexOf(' ')
|
||||
const name = line.slice(0, indexOfNameValueSeparator)
|
||||
const value = line.slice(indexOfNameValueSeparator + 1)
|
||||
if (name.length > 0) {
|
||||
map.set(name, value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return map
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,9 @@ const temp = require('temp').track()
|
||||
const parseCommandLine = require('./parse-command-line')
|
||||
const startCrashReporter = require('../crash-reporter-start')
|
||||
const atomPaths = require('../atom-paths')
|
||||
const ElectronSwitchStore = require('./electron-switch-store')
|
||||
const fs = require('fs')
|
||||
const CSON = require('season')
|
||||
const Config = require('../config')
|
||||
|
||||
module.exports = function start (resourcePath, startTime) {
|
||||
global.shellStartTime = startTime
|
||||
@@ -40,11 +42,10 @@ module.exports = function start (resourcePath, startTime) {
|
||||
atomPaths.setUserData(app)
|
||||
setupCompileCache()
|
||||
|
||||
const electronSwitchStore = new ElectronSwitchStore({
|
||||
filePath: path.join(process.env.ATOM_HOME, '.electron-switches')
|
||||
})
|
||||
for (const [name, value] of electronSwitchStore.entries()) {
|
||||
app.commandLine.appendSwitch(name, value)
|
||||
const config = getConfig()
|
||||
const colorProfile = config.get('core.forceColorProfile')
|
||||
if (colorProfile) {
|
||||
app.commandLine.appendSwitch('force-color-profile', colorProfile)
|
||||
}
|
||||
|
||||
if (handleStartupEventWithSquirrel()) {
|
||||
@@ -105,3 +106,14 @@ function setupCompileCache () {
|
||||
CompileCache.setAtomHomeDirectory(process.env.ATOM_HOME)
|
||||
CompileCache.install(process.resourcesPath, require)
|
||||
}
|
||||
|
||||
function getConfig () {
|
||||
const configFilePath = fs.existsSync(path.join(process.env.ATOM_HOME, 'config.json'))
|
||||
? path.join(process.env.ATOM_HOME, 'config.json')
|
||||
: path.join(process.env.ATOM_HOME, 'config.cson')
|
||||
|
||||
const configFileData = CSON.readFileSync(configFilePath)
|
||||
const config = new Config()
|
||||
config.resetUserSettings(configFileData)
|
||||
return config
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user