添加仅保存最近latest.json选项
This commit is contained in:
		@@ -6,6 +6,9 @@ const path = require('path');
 | 
			
		||||
 | 
			
		||||
const DATA_FOLDER = path.join(path.dirname(__dirname), process.env.DATA_FOLDER ?? 'data');
 | 
			
		||||
console.log("DATA_FOLDER", DATA_FOLDER);
 | 
			
		||||
createFolder(DATA_FOLDER); // 程序运行就保证 data 目录存在
 | 
			
		||||
 | 
			
		||||
const LATEST_DATA_ONLY = process.env.LATEST_DATA_ONLY == true;
 | 
			
		||||
 | 
			
		||||
// 请求微博热搜 APi 接口
 | 
			
		||||
async function getApiResult(url) {
 | 
			
		||||
@@ -44,6 +47,7 @@ async function createFolder(folderToCreate) {
 | 
			
		||||
 | 
			
		||||
// 保存 JSON
 | 
			
		||||
function saveJSON({ now, fileNameSuffix, object, compress = true, uncompress = true }) {
 | 
			
		||||
    if (LATEST_DATA_ONLY) return;
 | 
			
		||||
 | 
			
		||||
    let year = now.substring(0, 4);
 | 
			
		||||
    let month = now.substring(5, 7);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user