mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-23 11:16:39 +00:00
fix(app): Fix config path on Windows, typos
This commit is contained in:
parent
e0ebdc9045
commit
3d47f494a8
@ -41,24 +41,15 @@ const JSON_INDENT = 2
|
||||
*/
|
||||
const USER_DATA_DIR = electron.remote.app.getPath('userData')
|
||||
|
||||
/**
|
||||
* @summary Local settings filename
|
||||
* @constant
|
||||
* @type {String}
|
||||
*/
|
||||
const RCFILE = '.etcher.json'
|
||||
|
||||
/**
|
||||
* @summary Configuration file path
|
||||
* @type {String}
|
||||
* @constant
|
||||
*/
|
||||
const HOME_CONFIG_PATH = process.platform === 'win32'
|
||||
? path.join(USER_DATA_DIR, RCFILE)
|
||||
: path.join(USER_DATA_DIR, 'config.json')
|
||||
const CONFIG_PATH = path.join(USER_DATA_DIR, 'config.json')
|
||||
|
||||
/**
|
||||
* @summary Read a local .etcherrc file
|
||||
* @summary Read a local config.json file
|
||||
* @function
|
||||
* @private
|
||||
*
|
||||
@ -67,7 +58,7 @@ const HOME_CONFIG_PATH = process.platform === 'win32'
|
||||
* @returns {Promise}
|
||||
*
|
||||
* @example
|
||||
* readConfigFile('.etcherrc').then((settings) => {
|
||||
* readConfigFile('config.json').then((settings) => {
|
||||
* console.log(settings)
|
||||
* })
|
||||
*/
|
||||
@ -88,7 +79,7 @@ const readConfigFile = (filename) => {
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Read a local .etcherrc file
|
||||
* @summary Write to the local configuration file
|
||||
* @function
|
||||
* @private
|
||||
*
|
||||
@ -98,7 +89,7 @@ const readConfigFile = (filename) => {
|
||||
* @returns {Promise}
|
||||
*
|
||||
* @example
|
||||
* writeConfigFile('.etcherrc', { something: 'good' })
|
||||
* writeConfigFile('config.json', { something: 'good' })
|
||||
* .then(() => {
|
||||
* console.log('data written')
|
||||
* })
|
||||
@ -130,7 +121,7 @@ const writeConfigFile = (filename, data) => {
|
||||
* });
|
||||
*/
|
||||
exports.readAll = () => {
|
||||
return readConfigFile(HOME_CONFIG_PATH)
|
||||
return readConfigFile(CONFIG_PATH)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -150,7 +141,7 @@ exports.readAll = () => {
|
||||
* });
|
||||
*/
|
||||
exports.writeAll = (settings) => {
|
||||
return writeConfigFile(HOME_CONFIG_PATH, settings)
|
||||
return writeConfigFile(CONFIG_PATH, settings)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -170,7 +161,7 @@ exports.writeAll = (settings) => {
|
||||
*/
|
||||
exports.clear = () => {
|
||||
return new Bluebird((resolve, reject) => {
|
||||
fs.unlink(HOME_CONFIG_PATH, (error) => {
|
||||
fs.unlink(CONFIG_PATH, (error) => {
|
||||
if (error) {
|
||||
reject(error)
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user