forked from evergrand/sazs34_jd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
onlyOneExecute.js
35 lines (31 loc) · 1.08 KB
/
onlyOneExecute.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 exec = require("child_process").execSync;
const fs = require("fs");
const axios = require("axios");
const smartReplace = require("./smartReplace");
async function changeFiele() {
let response = await axios.get(process.env.SYNCURL);
let content = response.data;
content = await smartReplace.inject(content);
await fs.writeFileSync("./executeOnce.js", content, "utf8");
console.log("替换变量完毕");
}
async function start() {
console.log(`北京时间 (UTC+08):${new Date(new Date().getTime() + 8 * 60 * 60 * 1000).toLocaleString()}}`);
if (process.env.JD_COOKIE) {
console.log(`当前共${process.env.JD_COOKIE.split("&").length}个账号需要签到`);
} else {
console.log("请填写 JD_COOKIE 后在继续");
}
if (!process.env.SYNCURL) {
console.log("请填写 SYNCURL 后在继续");
return;
}
try {
await changeFiele();
await exec("node executeOnce.js", { stdio: "inherit" });
} catch (e) {
console.log("执行异常:" + e);
}
console.log("执行完毕");
}
start();