From 8417be9a99c06b283a6051ce4e7765531fdb666b Mon Sep 17 00:00:00 2001 From: whyour Date: Sun, 8 Sep 2024 17:54:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=BB=E5=8A=A1=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E5=89=8D=E5=91=BD=E4=BB=A4=E9=94=99=E8=AF=AF=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/preload/sitecustomize.js | 14 +++++++++++--- shell/preload/sitecustomize.py | 12 +++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/shell/preload/sitecustomize.js b/shell/preload/sitecustomize.js index 977639fb44e..d0b5d55dddf 100644 --- a/shell/preload/sitecustomize.js +++ b/shell/preload/sitecustomize.js @@ -1,5 +1,6 @@ const { execSync } = require('child_process'); require(`./env.js`); + function expandRange(rangeStr, max) { const tempRangeStr = rangeStr .trim() @@ -30,8 +31,6 @@ function run() { task_before, } = process.env; - require(file_task_before_js); - try { const splitStr = '__sitecustomize__'; const fileName = process.argv[1].replace(`${dir_scripts}/`, ''); @@ -60,10 +59,19 @@ function run() { } } catch (error) { if (!error.message.includes('spawnSync /bin/sh E2BIG')) { - console.log(`run task before error: `, error); + console.log(`❌ run task before error: `, error); + } else { + console.log( + `❌ The environment variable is too large. It is recommended to use task_before.js instead of task_before.sh`, + ); + } + if (task_before) { + console.log('执行前置命令结束\n'); } } + require(file_task_before_js); + if (envParam && numParam) { const array = (process.env[envParam] || '').split('&'); const runArr = expandRange(numParam, array.length); diff --git a/shell/preload/sitecustomize.py b/shell/preload/sitecustomize.py index bd73978ab9c..b3437931e0a 100644 --- a/shell/preload/sitecustomize.py +++ b/shell/preload/sitecustomize.py @@ -35,8 +35,6 @@ def expand_range(range_str, max_value): def run(): - import task_before - try: split_str = "__sitecustomize__" file_name = sys.argv[0].replace(f"{os.getenv('dir_scripts')}/", "") @@ -68,10 +66,18 @@ def run(): except OSError as error: error_message = str(error) if "Argument list too long" not in error_message: - print(f"run task before error: {error}") + print(f"❌ run task before error: {error}") + else: + print( + "❌ The environment variable is too large. It is recommended to use task_before.js instead of task_before.sh" + ) + if task_before: + print("执行前置命令结束") except Exception as error: print(f"run task before error: {error}") + import task_before + env_param = os.getenv("envParam") num_param = os.getenv("numParam")