Create temp directory if it doesn't exist before saving images and cache
This commit is contained in:
parent
e7f142ecff
commit
570e1b4679
2 changed files with 19 additions and 1 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue