fixed config file path

This commit is contained in:
陆柯 2019-09-10 12:33:43 +08:00
parent 3241338b1d
commit fce90c90eb

View File

@ -10,17 +10,18 @@ var Config = {}
// 读取配置文件 // 读取配置文件
try { try {
if (fs.existsSync('./ConfigBasic.js')) { let configFile
Config = require('./ConfigBasic.js') if (fs.existsSync(configFile=path.join(process.cwd(), 'ConfigBasic.js'))) {
console.info('ConfigBasic loaded') Config = require(configFile)
console.info(`${configFile} loaded`)
} }
if (fs.existsSync('./ConfigCustom.js')) { // 如果存在,覆盖掉 ConfigBasic 里的默认参数 if (fs.existsSync(configFile=path.join(process.cwd(), 'ConfigCustom.js'))) { // 如果存在,覆盖掉 ConfigBasic 里的默认参数
Config = deepmerge(Config, require('./ConfigCustom.js')) // 注意objectMerge后产生了一个新的对象而不是在原来的Config里添加 Config = deepmerge(Config, require(configFile)) // 注意objectMerge后产生了一个新的对象而不是在原来的Config里添加
console.info('ConfigCustom loaded') console.info(`${configFile} loaded`)
} }
if (fs.existsSync('./ConfigSecret.js')) { // 如果存在,覆盖掉 ConfigBasic 和 ConfigCustom 里的参数 if (fs.existsSync(configFile=path.join(process.cwd(), 'ConfigSecret.js'))) { // 如果存在,覆盖掉 ConfigBasic 和 ConfigCustom 里的参数
Config = deepmerge(Config, require('./ConfigSecret.js')) Config = deepmerge(Config, require(pconfigFile))
console.info('ConfigSecret loaded') console.info(`${configFile} loaded`)
} }
} catch (err) { } catch (err) {
console.error('Loading config files failed: ' + err.message) console.error('Loading config files failed: ' + err.message)
@ -34,7 +35,7 @@ commander
.option('-d, --dist <dist>', `Folder to deploy on the target server. Default to ${Config.deploy.dist}`) .option('-d, --dist <dist>', `Folder to deploy on the target server. Default to ${Config.deploy.dist}`)
.option('-u, --user <user>', `User id to login the target server. Default to ${Config.deploy.user}`) .option('-u, --user <user>', `User id to login the target server. Default to ${Config.deploy.user}`)
.option('-k, --key <key>', `User private key file to login the target server. Default to ${Config.deploy.key}`) .option('-k, --key <key>', `User private key file to login the target server. Default to ${Config.deploy.key}`)
.option('-p, --password <password>', `User password to login the target server. You may have to enclose it in "". Default to ${Config.deploy.password}`) .option('-p, --password <password>', `User password to login the target server. You may have to enclose it in "". Default to "${Config.deploy.password}"`)
.option('-l, --local <folder>', `Local folder to copy from. Default to ${Config.deploy.local}`) .option('-l, --local <folder>', `Local folder to copy from. Default to ${Config.deploy.local}`)
.parse(process.argv) .parse(process.argv)