From c958fa45270736e0d8eaf07ed04519e392a0ce6a Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期四, 12 九月 2024 13:46:47 +0800 Subject: [PATCH] dev 切换分支 --- scripts/helper.js | 29 ++++++++++++++++++++++++++--- scripts/dev.js | 5 ++++- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/scripts/dev.js b/scripts/dev.js index 1f1941c..f2a3a3e 100644 --- a/scripts/dev.js +++ b/scripts/dev.js @@ -1,5 +1,8 @@ -const { copyFile } = require('./helper'); +const { copyFile,customerList ,checkCustomer,changeBranch} = require('./helper'); const { execSync } = require('child_process'); +const customer = customerList[0]?.split(':')[0]; +checkCustomer('npm run dev', customer); +changeBranch(); copyFile('npm run dev'); try { diff --git a/scripts/helper.js b/scripts/helper.js index 63a6b27..e1daff8 100644 --- a/scripts/helper.js +++ b/scripts/helper.js @@ -16,8 +16,13 @@ const customerListDir = path.join(rootDir, 'customer_list'); const customerProjectListDir = path.join(rootDir, 'src', 'views', 'project'); const homeDir = os.homedir(); -// const deployEnv = process.argv[3]; +const item = customerList[0]; +const customerSplit = item?.split(':'); +const deployEnv = customerSplit?.[1]; +// 鏄惁涓虹敓浜х幆澧� +const isPro = deployEnv === 'pro'; +// const deployEnv = process.argv[3]; const logColor = (text, color) => { console.log(chalk[color](text)); @@ -30,7 +35,6 @@ const logSuccess = (text) => { logColor(text, 'green'); }; - const checkCustomerDirExist = (customer) => { const customerDir = path.join(customerListDir, customer); @@ -100,6 +104,7 @@ function copyFile(command) { const customer = customerList[0]?.split(':')[0]; checkCustomer(command, customer); + // 纭繚 public 鏂囦欢锛屼笉瀛樺湪鍒欏垱寤� fs.ensureDirSync(publicDir); // 娓呯┖ public 鏂囦欢澶� @@ -229,6 +234,21 @@ }; /** + * 鍒囨崲鍒嗘敮 + */ +const changeBranch = () => { + if (isPro) { + try { + execSync('git checkout master', { stdio: 'inherit' }); + } catch (error) {} + } else { + try { + execSync('git checkout test', { stdio: 'inherit' }); + } catch (error) {} + } +}; + +/** * 閫�鍑鸿剼鏈� */ const exit = () => { @@ -243,6 +263,7 @@ }; module.exports = { + isPro, customerList, //#region ====================== 鏂囦欢璺緞 ====================== rootDir, @@ -269,5 +290,7 @@ exit, checkFileExist, - replaceFileContent + replaceFileContent, + + changeBranch }; -- Gitblit v1.9.3