wujingjing
2024-09-12 983001d3238e622157e1b0ee41f506458825a8f6
scripts/publish.js
@@ -1,17 +1,19 @@
const { execSync } = require('child_process');
const { customerList, checkCustomerDirExist, logError } = require('./helper');
const { customerList, checkCustomerDirExist, logError,exit,firstCustomerName,changeBranch } = 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); // 退出脚本
   exit(); // 退出脚本
}
changeBranch();
customerList.forEach((item) => {
   const customerSplit = item.split(':');
@@ -19,9 +21,11 @@
   checkCustomerDirExist(customerName);
});
try {
   // 随便拿第一个用于 build
   execSync(`npm run build ${customerList[0].split(':')[0]}`, { stdio: 'inherit' });
   execSync(`npm run build ${firstCustomerName}`, { stdio: 'inherit' });
} catch (error) {}
try {