mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-28 05:36:34 +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')
|
const USER_DATA_DIR = electron.remote.app.getPath('userData')
|
||||||
|
|
||||||
/**
|
|
||||||
* @summary Local settings filename
|
|
||||||
* @constant
|
|
||||||
* @type {String}
|
|
||||||
*/
|
|
||||||
const RCFILE = '.etcher.json'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Configuration file path
|
* @summary Configuration file path
|
||||||
* @type {String}
|
* @type {String}
|
||||||
* @constant
|
* @constant
|
||||||
*/
|
*/
|
||||||
const HOME_CONFIG_PATH = process.platform === 'win32'
|
const CONFIG_PATH = path.join(USER_DATA_DIR, 'config.json')
|
||||||
? path.join(USER_DATA_DIR, RCFILE)
|
|
||||||
: path.join(USER_DATA_DIR, 'config.json')
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Read a local .etcherrc file
|
* @summary Read a local config.json file
|
||||||
* @function
|
* @function
|
||||||
* @private
|
* @private
|
||||||
*
|
*
|
||||||
@ -67,7 +58,7 @@ const HOME_CONFIG_PATH = process.platform === 'win32'
|
|||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* readConfigFile('.etcherrc').then((settings) => {
|
* readConfigFile('config.json').then((settings) => {
|
||||||
* console.log(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
|
* @function
|
||||||
* @private
|
* @private
|
||||||
*
|
*
|
||||||
@ -98,7 +89,7 @@ const readConfigFile = (filename) => {
|
|||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* writeConfigFile('.etcherrc', { something: 'good' })
|
* writeConfigFile('config.json', { something: 'good' })
|
||||||
* .then(() => {
|
* .then(() => {
|
||||||
* console.log('data written')
|
* console.log('data written')
|
||||||
* })
|
* })
|
||||||
@ -130,7 +121,7 @@ const writeConfigFile = (filename, data) => {
|
|||||||
* });
|
* });
|
||||||
*/
|
*/
|
||||||
exports.readAll = () => {
|
exports.readAll = () => {
|
||||||
return readConfigFile(HOME_CONFIG_PATH)
|
return readConfigFile(CONFIG_PATH)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -150,7 +141,7 @@ exports.readAll = () => {
|
|||||||
* });
|
* });
|
||||||
*/
|
*/
|
||||||
exports.writeAll = (settings) => {
|
exports.writeAll = (settings) => {
|
||||||
return writeConfigFile(HOME_CONFIG_PATH, settings)
|
return writeConfigFile(CONFIG_PATH, settings)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -170,7 +161,7 @@ exports.writeAll = (settings) => {
|
|||||||
*/
|
*/
|
||||||
exports.clear = () => {
|
exports.clear = () => {
|
||||||
return new Bluebird((resolve, reject) => {
|
return new Bluebird((resolve, reject) => {
|
||||||
fs.unlink(HOME_CONFIG_PATH, (error) => {
|
fs.unlink(CONFIG_PATH, (error) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
reject(error)
|
reject(error)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user