增加 task_before.js 和 task_before.py 文件,在执行任务前执行,避免环境变量过大报错

This commit is contained in:
whyour
2024-07-22 01:07:00 +08:00
parent eb5cc3943d
commit e694570f1a
7 changed files with 114 additions and 70 deletions
+18
View File
@@ -31,6 +31,8 @@ const scriptNotifyPyFile = path.join(scriptPath, 'notify.py');
const jsNotifyFile = path.join(preloadPath, 'notify.js');
const pyNotifyFile = path.join(preloadPath, 'notify.py');
const TaskBeforeFile = path.join(configPath, 'task_before.sh');
const TaskBeforeJsFile = path.join(configPath, 'task_before.js');
const TaskBeforePyFile = path.join(configPath, 'task_before.py');
const TaskAfterFile = path.join(configPath, 'task_after.sh');
const homedir = os.homedir();
const sshPath = path.resolve(homedir, '.ssh');
@@ -53,6 +55,8 @@ export default async () => {
const scriptNotifyJsFileExist = await fileExist(scriptNotifyJsFile);
const scriptNotifyPyFileExist = await fileExist(scriptNotifyPyFile);
const TaskBeforeFileExist = await fileExist(TaskBeforeFile);
const TaskBeforeJsFileExist = await fileExist(TaskBeforeJsFile);
const TaskBeforePyFileExist = await fileExist(TaskBeforePyFile);
const TaskAfterFileExist = await fileExist(TaskAfterFile);
if (!configDirExist) {
@@ -125,6 +129,20 @@ export default async () => {
await fs.writeFile(TaskBeforeFile, await fs.readFile(sampleTaskShellFile));
}
if (!TaskBeforeJsFileExist) {
await fs.writeFile(
TaskBeforeJsFile,
'// The JavaScript code that executes before the JavaScript task execution will execute.',
);
}
if (!TaskBeforePyFileExist) {
await fs.writeFile(
TaskBeforePyFile,
'# The Python code that executes before the Python task execution will execute.',
);
}
if (!TaskAfterFileExist) {
await fs.writeFile(TaskAfterFile, await fs.readFile(sampleTaskShellFile));
}