optimize: 兼容使用 `1.7.3` 及以下版本的配置文件 (#339)
parent
486912c0fe
commit
cc833719bc
|
@ -23,15 +23,23 @@ function _getRemoteSavePath (suffix = '') {
|
|||
if (!fs.existsSync(dir)) {
|
||||
fs.mkdirSync(dir)
|
||||
}
|
||||
return path.join(dir, `remote_config${suffix}.json5`)
|
||||
return path.join(dir, `/remote_config${suffix}.json5`)
|
||||
}
|
||||
|
||||
function _getConfigPath () {
|
||||
const dir = getDefaultConfigBasePath()
|
||||
if (!fs.existsSync(dir)) {
|
||||
fs.mkdirSync(dir)
|
||||
} else {
|
||||
// 兼容1.7.3及以下版本的配置文件处理逻辑
|
||||
const newFilePath = path.join(dir, '/config.json')
|
||||
const oldFilePath = path.join(dir, '/config.json5')
|
||||
if (!fs.existsSync(newFilePath) && fs.existsSync(oldFilePath)) {
|
||||
return oldFilePath // 如果新文件不存在,且旧文件存在,则返回旧文件路径
|
||||
}
|
||||
return newFilePath
|
||||
}
|
||||
return path.join(dir, 'config.json')
|
||||
return path.join(dir, '/config.json')
|
||||
}
|
||||
|
||||
let timer
|
||||
|
|
|
@ -6,11 +6,11 @@ function getUserBasePath () {
|
|||
}
|
||||
|
||||
function getRootCaCertPath () {
|
||||
return getUserBasePath() + '/dev-sidecar.ca.crt'
|
||||
return path.join(getUserBasePath(), '/dev-sidecar.ca.crt')
|
||||
}
|
||||
|
||||
function getRootCaKeyPath () {
|
||||
return getUserBasePath() + '/dev-sidecar.ca.key.pem'
|
||||
return path.join(getUserBasePath(), '/dev-sidecar.ca.key.pem')
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
|
@ -138,8 +138,16 @@ function _getSettingsPath () {
|
|||
const dir = getDefaultConfigBasePath()
|
||||
if (!fs.existsSync(dir)) {
|
||||
fs.mkdirSync(dir)
|
||||
} else {
|
||||
// 兼容1.7.3及以下版本的配置文件处理逻辑
|
||||
const newFilePath = path.join(dir, '/setting.json')
|
||||
const oldFilePath = path.join(dir, '/setting.json5')
|
||||
if (!fs.existsSync(newFilePath) && fs.existsSync(oldFilePath)) {
|
||||
return oldFilePath // 如果新文件不存在,且旧文件存在,则返回旧文件路径
|
||||
}
|
||||
return newFilePath
|
||||
}
|
||||
return dir + '/setting.json'
|
||||
return path.join(dir, '/setting.json')
|
||||
}
|
||||
|
||||
function invoke (api, param) {
|
||||
|
|
Loading…
Reference in New Issue