|
|
@ -2,7 +2,7 @@
|
|
|
|
* @Author: ch
|
|
|
|
* @Author: ch
|
|
|
|
* @Date: 2022-05-05 14:40:00
|
|
|
|
* @Date: 2022-05-05 14:40:00
|
|
|
|
* @LastEditors: ch
|
|
|
|
* @LastEditors: ch
|
|
|
|
* @LastEditTime: 2022-05-07 10:09:54
|
|
|
|
* @LastEditTime: 2022-05-07 10:51:53
|
|
|
|
* @Description: 根据git分支生成对应环境的环境变量
|
|
|
|
* @Description: 根据git分支生成对应环境的环境变量
|
|
|
|
* 开发时如果环境变量换了,可以不用重启服务,直接运行node env.config.js即可
|
|
|
|
* 开发时如果环境变量换了,可以不用重启服务,直接运行node env.config.js即可
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -25,21 +25,16 @@ const envConfig = {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const branch = getRepoInfo().branch; // 调用获取git信息
|
|
|
|
const branch = getRepoInfo().branch; // 调用获取git信息
|
|
|
|
let curEnvConfig = {};
|
|
|
|
let curEnvConfig = null;
|
|
|
|
switch (branch){
|
|
|
|
const argv = global.process.argv;
|
|
|
|
case 'msb_test':
|
|
|
|
for(key in envConfig){
|
|
|
|
curEnvConfig = envConfig.test;
|
|
|
|
if(argv.includes(`--ENV:${key}`)){
|
|
|
|
break;
|
|
|
|
curEnvConfig = envConfig[key];
|
|
|
|
case 'msb_beta':
|
|
|
|
break;
|
|
|
|
curEnvConfig = envConfig.beta;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'msb_prod':
|
|
|
|
if(!curEnvConfig){
|
|
|
|
curEnvConfig = envConfig.prod;
|
|
|
|
curEnvConfig = envConfig.dev;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
curEnvConfig = envConfig.dev;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fs.writeFileSync(`${path.resolve(__dirname, './plugins/config')}/env.js`,
|
|
|
|
fs.writeFileSync(`${path.resolve(__dirname, './plugins/config')}/env.js`,
|
|
|
|
`const ENV = ${JSON.stringify(curEnvConfig)}; export default ENV;`);
|
|
|
|
`const ENV = ${JSON.stringify(curEnvConfig)}; export default ENV;`);
|
|
|
|