Skip to content

Commit

Permalink
Ensure ICS generation script creates non-existent directories
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshStrobl committed Aug 23, 2023
1 parent 336b673 commit 1aea8b3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/scripts/genCalendar.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { writeFileSync } from "fs";
import { mkdirSync, writeFileSync } from "fs";
import type { DateArray, EventAttributes } from "ics";
import { createEvents } from "ics";
import { join } from "path";
Expand Down Expand Up @@ -29,6 +29,8 @@ const scheduleToEvents = UnifiedReleaseSchedules.reduce<EventAttributes[]>(
);

const { error, value } = createEvents(scheduleToEvents);
const fsPath = join(process.cwd(), "static", "calendars", "third-party-schedules.ics");
const folderPath = join(process.cwd(), "static", "calendars");
mkdirSync(folderPath, { recursive: true });
const fsPath = join(folderPath, "third-party-schedules.ics");
if (!error) writeFileSync(fsPath, value, { mode: 755 });
if (error) console.error(error);

0 comments on commit 1aea8b3

Please sign in to comment.