forked from 0xsongsu/dailytask
-
Notifications
You must be signed in to change notification settings - Fork 0
/
taskRunner.js
37 lines (31 loc) · 1.15 KB
/
taskRunner.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
const { spawn } = require('child_process');
const readlineSync = require('readline-sync');
const path = require('path');
// 脚本路径列表
const scripts = [
'./src/web3go/reikiTask.js',
'./src/robots/getTicket.js',
'./src/robots/claimRaffle.js',
'./src/lāvaNet/lavaRun.js',
];
const password = readlineSync.question('请输入密码: ', {
hideEchoBack: true // 密码输入时不显示字符
});
runScript(0);
function runScript(index) {
if (index < scripts.length) {
const scriptName = path.basename(scripts[index], '.js');
console.log(`开始执行脚本: ${scriptName}`);
const childProcess = spawn('node', [scripts[index]], {
env: { ...process.env, SCRIPT_PASSWORD: password },
stdio: 'inherit'
});
childProcess.on('close', (code) => {
console.log(`脚本 ${scriptName} 执行完成,退出码 ${code}`);
if (index + 1 < scripts.length) {
console.log(`脚本 ${scriptName} 执行完成,开始执行脚本 ${path.basename(scripts[index + 1], '.js')}`);
}
runScript(index + 1);
});
}
}