-
Notifications
You must be signed in to change notification settings - Fork 0
/
ele.js
49 lines (41 loc) · 1.11 KB
/
ele.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
* cron: 1 1 1 1 1
* 只添加这个定时就可以了 自己修改下面脚本路径就可以自动一键启动全部
*饿了么一键全任务-可自己关了 单独运行
*/
const $ = new Env('脚本一键启动');
const { exec } = require('child_process');
function runScript(scriptPath) {
return new Promise((resolve, reject) => {
const command = `node ${scriptPath}`;
const childProcess = exec(command);
childProcess.stdout.on('data', (data) => {
console.log(`${data}`);
});
childProcess.stderr.on('data', (data) => {
console.error(`[${scriptPath}] stderr: ${data}`);
});
childProcess.on('close', (code) => {
if (code === 0) {
resolve();
} else {
reject(new Error(`Script ${scriptPath} exited with code ${code}`));
}
});
});
}
const scripts = [
'../',
];
async function runScripts() {
for (const script of scripts) {
// console.log(`查找: ${script}`);
try {
await runScript(script);
} catch (error) {
console.error(`Error running script ${script}:`, error);
}
}
}
// 执行所有脚本
runScripts();