mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-06-04 21:01:17 +08:00
fix: fs.rm node12
This commit is contained in:
parent
d9cecbe163
commit
b91a4f979d
23
lib/utils.js
23
lib/utils.js
@ -370,6 +370,25 @@ const utils = {
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* deleteFolderRecursive
|
||||||
|
* @param {*} url
|
||||||
|
*/
|
||||||
|
deleteFolderRecursive(url) {
|
||||||
|
var files = [];
|
||||||
|
if (fs.existsSync(url)) {
|
||||||
|
files = fs.readdirSync(url);
|
||||||
|
files.forEach(function (file) {
|
||||||
|
var curPath = path.join(url, file);
|
||||||
|
if (fs.statSync(curPath).isDirectory()) {
|
||||||
|
utils.deleteFolderRecursive(curPath);
|
||||||
|
} else {
|
||||||
|
fs.unlinkSync(curPath);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
fs.rmdirSync(url);
|
||||||
|
}
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* 读取dyid文件
|
* 读取dyid文件
|
||||||
* @param {number} num
|
* @param {number} num
|
||||||
@ -433,9 +452,7 @@ const utils = {
|
|||||||
* 清空lottery_info
|
* 清空lottery_info
|
||||||
*/
|
*/
|
||||||
clearLotteryInfo() {
|
clearLotteryInfo() {
|
||||||
return new Promise((resolve) => {
|
utils.deleteFolderRecursive(utils.lottery_info_dir)
|
||||||
fs.rm(utils.lottery_info_dir, { recursive: true, force: true }, resolve)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
4
main.js
4
main.js
@ -158,13 +158,13 @@ function initConfig() {
|
|||||||
log.warn('结束运行', '5秒后自动退出');
|
log.warn('结束运行', '5秒后自动退出');
|
||||||
await delay(5 * 1000);
|
await delay(5 * 1000);
|
||||||
} else {
|
} else {
|
||||||
await clearLotteryInfo();
|
clearLotteryInfo();
|
||||||
while (loop_wait) {
|
while (loop_wait) {
|
||||||
log.info('程序休眠', `${loop_wait / 1000}秒后再次启动`)
|
log.info('程序休眠', `${loop_wait / 1000}秒后再次启动`)
|
||||||
await delay(loop_wait)
|
await delay(loop_wait)
|
||||||
if (initEnv() || initConfig()) return;
|
if (initEnv() || initConfig()) return;
|
||||||
await main()
|
await main()
|
||||||
await clearLotteryInfo();
|
clearLotteryInfo();
|
||||||
}
|
}
|
||||||
log.info('结束运行', '未在config.js中设置休眠时间')
|
log.info('结束运行', '未在config.js中设置休眠时间')
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user