Create temp directory if it doesn't exist before saving images and cache

This commit is contained in:
암냥 2025-09-21 23:49:27 +09:00
commit 570e1b4679
2 changed files with 19 additions and 1 deletions

View file

@ -1,4 +1,4 @@
import { writeFileSync, existsSync, readFileSync } from "fs";
import { writeFileSync, existsSync, readFileSync, mkdirSync } from "fs";
import * as cheerio from "cheerio";
const CACHE_FILE = "./temp/scheduleCache.json";
@ -99,6 +99,11 @@ export async function getAllSchedules(
const schedule = Object.assign({}, ...results);
// temp 폴더가 없으면 생성
if (!existsSync("./temp")) {
mkdirSync("./temp", { recursive: true });
}
writeFileSync(CACHE_FILE, JSON.stringify(schedule, null, 2), "utf-8");
console.log(`📦 캐시 저장됨 → ${CACHE_FILE}`);
return schedule;