mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-25 16:36:07 +08:00
修复任务执行前命令错误提示
This commit is contained in:
parent
c3704502bf
commit
69fcf45231
|
@ -1,5 +1,6 @@
|
||||||
const { execSync } = require('child_process');
|
const { execSync } = require('child_process');
|
||||||
require(`./env.js`);
|
require(`./env.js`);
|
||||||
|
|
||||||
function expandRange(rangeStr, max) {
|
function expandRange(rangeStr, max) {
|
||||||
const tempRangeStr = rangeStr
|
const tempRangeStr = rangeStr
|
||||||
.trim()
|
.trim()
|
||||||
|
@ -30,8 +31,6 @@ function run() {
|
||||||
task_before,
|
task_before,
|
||||||
} = process.env;
|
} = process.env;
|
||||||
|
|
||||||
require(file_task_before_js);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const splitStr = '__sitecustomize__';
|
const splitStr = '__sitecustomize__';
|
||||||
const fileName = process.argv[1].replace(`${dir_scripts}/`, '');
|
const fileName = process.argv[1].replace(`${dir_scripts}/`, '');
|
||||||
|
@ -60,10 +59,19 @@ function run() {
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (!error.message.includes('spawnSync /bin/sh E2BIG')) {
|
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\n`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (task_before) {
|
||||||
|
console.log('执行前置命令结束\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
require(file_task_before_js);
|
||||||
|
|
||||||
if (envParam && numParam) {
|
if (envParam && numParam) {
|
||||||
const array = (process.env[envParam] || '').split('&');
|
const array = (process.env[envParam] || '').split('&');
|
||||||
const runArr = expandRange(numParam, array.length);
|
const runArr = expandRange(numParam, array.length);
|
||||||
|
|
|
@ -35,8 +35,6 @@ def expand_range(range_str, max_value):
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
import task_before
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
split_str = "__sitecustomize__"
|
split_str = "__sitecustomize__"
|
||||||
file_name = sys.argv[0].replace(f"{os.getenv('dir_scripts')}/", "")
|
file_name = sys.argv[0].replace(f"{os.getenv('dir_scripts')}/", "")
|
||||||
|
@ -68,10 +66,18 @@ def run():
|
||||||
except OSError as error:
|
except OSError as error:
|
||||||
error_message = str(error)
|
error_message = str(error)
|
||||||
if "Argument list too long" not in error_message:
|
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.py instead of task_before.sh\n"
|
||||||
|
)
|
||||||
|
if task_before:
|
||||||
|
print("执行前置命令结束")
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
print(f"run task before error: {error}")
|
print(f"run task before error: {error}")
|
||||||
|
|
||||||
|
import task_before
|
||||||
|
|
||||||
env_param = os.getenv("envParam")
|
env_param = os.getenv("envParam")
|
||||||
num_param = os.getenv("numParam")
|
num_param = os.getenv("numParam")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user