yangyin
2024-05-20 4871d8eaa2f06e5a044ea0435e8e2b962358e384
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const { execSync } = require('child_process');
 
const { customerList, checkCustomerDirExist, logError } = require('./helper');
// if (!customerList || customerList.length === 0) {
//     logError(`请正确使用命令 “npm run publish [customer1,customer2,customer3,...]”,
//     部署到生产环境写法:customer:pro
//     `);
//     process.exit(1); // 退出脚本
// }
 
if (customerList?.length !== 1) {
    logError(`请正确使用命令 “npm run publish customer”(目前只支持一次部署一个)`);
    process.exit(1); // 退出脚本
}
 
customerList.forEach((item) => {
    const customerSplit = item.split(':');
    const customerName = customerSplit[0];
    checkCustomerDirExist(customerName);
});
 
try {
    // 随便拿第一个用于 build
    execSync(`npm run build ${customerList[0].split(':')[0]}`, { stdio: 'inherit' });
} catch (error) {}
 
try {
    execSync(`npm run deploy "${customerList.join(' ')}"`, { stdio: 'inherit' });
} catch (error) {}