forked from Wenmoux/checkbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (35 loc) · 1.42 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
const sendmsg = require("./sendmsg");
const yaml = require("js-yaml");
const fs = require('fs');
const yargs = require('yargs');
var argv = yargs.argv;
global.config = yaml.load(fs.readFileSync('./config.yml', 'utf8'));
var signlist = ["lenovo","csdn"]
//自行添加任务 名字看脚本里的文件名 比如csdn.js 就填"csdn"
var signList = (argv._.length) > 0 ? argv._ : signlist
var logs = "";
start(signList);
function start(taskList) {
return new Promise(async (resolve) => {
try {
console.log("任务列表 " + argv._)
console.log("------------开始签到任务------------");
for (let i = 0; i < taskList.length; i++) {
console.log(`任务${i + 1}执行中`);
let exists = fs.existsSync(`./scripts/${taskList[i]}.js`)
if (exists) {
const task = require(`./scripts/${taskList[i]}.js`);
logs +=await task() + " \n\n";
} else {
logs += `${taskList[i]} 不存在该脚本文件,请确认输入是否有误\n\n`
console.log("不存在该脚本文件,请确认输入是否有误")
}
}
console.log("------------任务执行完毕------------\n");
await sendmsg(logs);
} catch (err) {
console.log(err);
}
resolve();
});
}