-
Notifications
You must be signed in to change notification settings - Fork 138
/
index.js
41 lines (36 loc) · 1.11 KB
/
index.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
const tasks = require('./task');
const fs = require('fs');
const path = require('path');
const _ = require('lodash');
(async function () {
const [cookie, serverSecret] = process.argv.slice(2);
console.log('cookie, serverSecret: ', cookie, serverSecret);
if (!cookie) {
console.error('----- [参数传递不正确,请检查参数] -----');
return;
}
// save user data
fs.writeFileSync(
path.join(__dirname, './task/userStatus.json'),
JSON.stringify({ cookie, serverSecret }),
{ encoding: 'utf-8' }
);
// run task
let taskLists = Object.keys(tasks);
taskLists = taskLists.filter((f) => !['Base', 'Index'].some((s) => f === s));
const taskList = taskLists
.reduce((acc, taskName) => {
const taskNameClass = require('./task/' + _.lowerFirst(taskName));
const newObj = new taskNameClass();
return acc.concat(newObj);
}, [])
.sort((x, y) => x.order() - y.order());
for (const task of taskList) {
console.info('\n');
console.info(`----- 执行 ${task.getTaskName()} -----`);
const r = await task.run();
if (r === false) {
break;
}
}
})();