diff --git a/index.js b/index.js index c64729d..7692bc9 100644 --- a/index.js +++ b/index.js @@ -38,7 +38,10 @@ const execute_command = require('./src/execute_command'); */ console.log("Start running ..."); -// 程序主函数 + +/** + * 程序主函数 + */ async function start() { // 爬取热搜数据 await get_hotband.main(); @@ -55,10 +58,14 @@ if (EXECUTE_AT_STARTUP) { // refer: https://www.npmjs.com/package/node-schedule const scheduleJob = schedule.scheduleJob('05 * * * * *', start); -// 定时推送 + +/** + * 定时将热搜数据推送到 Git 仓库 + */ async function pushToGitRepo() { let commands = [ 'git status', + 'git pull', 'git add .', `git commit -m "${new Date(Date.now() + 8 * 3600 * 1000).toISOString().substring(0, 19).replace('T', ' ')} update"`, `git push origin master`, diff --git a/src/get_hotband.js b/src/get_hotband.js index 8b5d31d..db1d14d 100644 --- a/src/get_hotband.js +++ b/src/get_hotband.js @@ -54,9 +54,9 @@ function saveJSON({ now, fileNameSuffix, object, compress = true, uncompress = t // console.log( "year, month, day, hour, minute: " + year + ", " + month + ", " + day + ", " + hour + ", " + minute); // 创建当前文件夹 - let folder = `${DATA_FOLDER}/${year}/${month}/${day}`; + let folder = `${DATA_FOLDER}/${fileNameSuffix}/${year}/${month}/${day}`; createFolder(folder); - let fileName = `${folder}/${year}${month}${day}_${hour}${minute}_${fileNameSuffix}`; + let fileName = `${folder}/${year}${month}${day}_${hour}${minute}`; // 生成文件名 // '2022-07-23T10:11:38.650Z' => '20220723_1011' @@ -229,9 +229,9 @@ async function main() { now: now, fileNameSuffix: `simplify`, object: data, - // compress: true, + compress: true, // uncompress: true, - compress: false, + // compress: false, uncompress: false, });