修复 node 前置逻辑

This commit is contained in:
whyour
2024-07-24 23:30:18 +08:00
parent 2ad6437672
commit eddd258614
3 changed files with 15 additions and 6 deletions
+2 -2
View File
@@ -41,10 +41,10 @@ function run() {
const fileName = process.argv[1].replace(`${dir_scripts}/`, '');
let command = `bash -c "source ${file_task_before} ${fileName}`;
if (task_before) {
command = `${command} && echo -e '执行前置命令\n' && eval "${task_before}" && echo -e '\n执行前置命令结束\n'`;
command = `${command} && echo -e '执行前置命令\n' && eval '${task_before}' && echo -e '\n执行前置命令结束\n'`;
}
const res = execSync(
`${command} && echo "${splitStr}" && NODE_OPTIONS= node -p 'JSON.stringify(process.env)'"`,
`${command} && echo -e '${splitStr}' && NODE_OPTIONS= node -p 'JSON.stringify(process.env)'"`,
{
encoding: 'utf-8',
},
+2 -2
View File
@@ -54,10 +54,10 @@ def run():
task_before = os.getenv("task_before")
if task_before:
command += f" && echo -e '执行前置命令\n' && eval \"{task_before}\" && echo -e '\n执行前置命令结束\n'"
command += f" && echo -e '执行前置命令\n' && eval '{task_before}' && echo -e '\n执行前置命令结束\n'"
python_command = "PYTHONPATH= python3 -c 'import os, json; print(json.dumps(dict(os.environ)))'"
command += f' && echo "{split_str}" && {python_command}"'
command += f" && echo -e '{split_str}' && {python_command}\""
res = subprocess.check_output(command, shell=True, encoding="utf-8")
output, env_str = res.split(split_str)