From fce90c90ebc88c559c9d6ff3ecf2e77ac2a8a0fe Mon Sep 17 00:00:00 2001 From: Luk Lu Date: Tue, 10 Sep 2019 12:33:43 +0800 Subject: [PATCH] fixed config file path --- deploy.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/deploy.js b/deploy.js index d071980..fbbfd94 100644 --- a/deploy.js +++ b/deploy.js @@ -10,17 +10,18 @@ var Config = {} // 读取配置文件 try { - if (fs.existsSync('./ConfigBasic.js')) { - Config = require('./ConfigBasic.js') - console.info('ConfigBasic loaded') + let configFile + if (fs.existsSync(configFile=path.join(process.cwd(), 'ConfigBasic.js'))) { + Config = require(configFile) + console.info(`${configFile} loaded`) } - if (fs.existsSync('./ConfigCustom.js')) { // 如果存在,覆盖掉 ConfigBasic 里的默认参数 - Config = deepmerge(Config, require('./ConfigCustom.js')) // 注意,objectMerge后,产生了一个新的对象,而不是在原来的Config里添加 - console.info('ConfigCustom loaded') + if (fs.existsSync(configFile=path.join(process.cwd(), 'ConfigCustom.js'))) { // 如果存在,覆盖掉 ConfigBasic 里的默认参数 + Config = deepmerge(Config, require(configFile)) // 注意,objectMerge后,产生了一个新的对象,而不是在原来的Config里添加 + console.info(`${configFile} loaded`) } - if (fs.existsSync('./ConfigSecret.js')) { // 如果存在,覆盖掉 ConfigBasic 和 ConfigCustom 里的参数 - Config = deepmerge(Config, require('./ConfigSecret.js')) - console.info('ConfigSecret loaded') + if (fs.existsSync(configFile=path.join(process.cwd(), 'ConfigSecret.js'))) { // 如果存在,覆盖掉 ConfigBasic 和 ConfigCustom 里的参数 + Config = deepmerge(Config, require(pconfigFile)) + console.info(`${configFile} loaded`) } } catch (err) { console.error('Loading config files failed: ' + err.message) @@ -34,7 +35,7 @@ commander .option('-d, --dist ', `Folder to deploy on the target server. Default to ${Config.deploy.dist}`) .option('-u, --user ', `User id to login the target server. Default to ${Config.deploy.user}`) .option('-k, --key ', `User private key file to login the target server. Default to ${Config.deploy.key}`) - .option('-p, --password ', `User password to login the target server. You may have to enclose it in "". Default to ${Config.deploy.password}`) + .option('-p, --password ', `User password to login the target server. You may have to enclose it in "". Default to "${Config.deploy.password}"`) .option('-l, --local ', `Local folder to copy from. Default to ${Config.deploy.local}`) .parse(process.argv)