diff --git a/.env b/.env index 494a7a5..59caf61 100644 --- a/.env +++ b/.env @@ -9,4 +9,8 @@ DATA_FOLDER=data # 是否在程序刚一启动时就抓取一次数据 # 1为是 -EXECUTE_AT_STARTUP=1 \ No newline at end of file +EXECUTE_AT_STARTUP=1 + +# 数据是否推送到Git仓库 +# 1为是 +PUSH_TO_GIT=0 \ No newline at end of file diff --git a/index.js b/index.js index 7692bc9..96881a4 100644 --- a/index.js +++ b/index.js @@ -14,6 +14,7 @@ dotenv.config('./.env'); // 导入 .env 文件中的环境变量 const DEBUG_MODE = process.env.DEBUG_MODE == true; const EXECUTE_AT_STARTUP = process.env.EXECUTE_AT_STARTUP == true; +const PUSH_TO_GIT = process.env.PUSH_TO_GIT == true; const ROOT_PATH = path.join(__dirname, process.env.DATA_FOLDER ?? 'data'); @@ -45,6 +46,12 @@ console.log("Start running ..."); async function start() { // 爬取热搜数据 await get_hotband.main(); + + // 调试模式下 + if (DEBUG_MODE) { + // 推送到 Git 仓库 + await pushToGitRepo(); + } } // 调试模式下,程序一启动就首先运行一次 @@ -63,6 +70,8 @@ const scheduleJob = schedule.scheduleJob('05 * * * * *', start); * 定时将热搜数据推送到 Git 仓库 */ async function pushToGitRepo() { + if (!PUSH_TO_GIT) return; + let commands = [ 'git status', 'git pull',