From d62396ca9861a09afa89e9909c9436e01b9a9c49 Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期四, 25 七月 2024 12:18:15 +0800 Subject: [PATCH] pageSize --- scripts/helper.js | 44 +++++++++++++++++++++++++++++++------------- 1 files changed, 31 insertions(+), 13 deletions(-) diff --git a/scripts/helper.js b/scripts/helper.js index fc930c7..63a6b27 100644 --- a/scripts/helper.js +++ b/scripts/helper.js @@ -18,6 +18,7 @@ const homeDir = os.homedir(); // const deployEnv = process.argv[3]; + const logColor = (text, color) => { console.log(chalk[color](text)); }; @@ -30,18 +31,6 @@ logColor(text, 'green'); }; -/** - * 妫�鏌ユ枃浠舵槸鍚﹀瓨鍦� - * @param {*} file - * @param {*} fileText - */ -const checkFileExist = (file, fileText) => { - // 楠岃瘉婧愭枃浠跺す鏄惁瀛樺湪 - if (!fs.existsSync(file)) { - console.error(chalk.red(`${fileText} "${file}" 涓嶅瓨鍦紒`)); - process.exit(1); // 閫�鍑鸿剼鏈� - } -}; const checkCustomerDirExist = (customer) => { const customerDir = path.join(customerListDir, customer); @@ -132,7 +121,18 @@ // 澶嶅埗婧愭枃浠跺す涓殑鎵�鏈夋枃浠跺埌 public 鏂囦欢澶� fs.copySync(customerDir, publicDir, { filter }); } - +/** + * 妫�鏌ユ枃浠舵槸鍚﹀瓨鍦� + * @param {*} file + * @param {*} fileText + */ +const checkFileExist = (file, fileText = '') => { + // 楠岃瘉婧愭枃浠跺す鏄惁瀛樺湪 + if (!fs.existsSync(file)) { + console.error(chalk.red(`${fileText ? fileText + ' ' : ''}"${file}" 涓嶅瓨鍦紒`)); + exit(); // 閫�鍑鸿剼鏈� + } +}; /** * 涓婁紶鏂囦欢鍒版湇鍔″櫒 * @param {*} command @@ -228,6 +228,20 @@ logSuccess(`馃帀馃帀馃帀銆�${customerList.join(',')}銆戦」鐩凡鎴愬姛閮ㄧ讲锛侌煄夝煄夝煄塦); }; +/** + * 閫�鍑鸿剼鏈� + */ +const exit = () => { + process.exit(1); // 閫�鍑鸿剼鏈� +}; + +const replaceFileContent = (path, callback) => { + const data = fs.readFileSync(path, 'utf8'); + if (!data) return; + const newData = callback(data); + fs.writeFileSync(path, newData, 'utf8'); +}; + module.exports = { customerList, //#region ====================== 鏂囦欢璺緞 ====================== @@ -252,4 +266,8 @@ moveProjectsToBakDir, restoreProjectDir, + + exit, + checkFileExist, + replaceFileContent }; -- Gitblit v1.9.3