Skip to content

Commit

Permalink
🐛 Ensure dir exists before writing
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Dec 3, 2020
1 parent 5eb3f47 commit 20aef14
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Octokit } from "@octokit/rest";
import slugify from "@sindresorhus/slugify";
import { CanvasRenderService } from "chartjs-node-canvas";
import dayjs from "dayjs";
import { ensureDir, readFile, readJson, writeFile, writeJson } from "fs-extra";
import { ensureDir, ensureFile, readFile, readJson, writeFile, writeJson } from "fs-extra";
import { safeLoad } from "js-yaml";
import { join } from "path";

Expand Down Expand Up @@ -217,6 +217,7 @@ export const generateGraphs = async () => {
];

for await (const dataItem of dataItems) {
await ensureFile(join(".", "graphs", dataItem[0]));
await writeFile(
join(".", "graphs", dataItem[0]),
await canvasRenderService.renderToBuffer({
Expand Down Expand Up @@ -256,6 +257,7 @@ export const generateGraphs = async () => {
);
}

await ensureFile(join(".", "graphs", slug, "response-time.png"));
await writeFile(
join(".", "graphs", slug, "response-time.png"),
await canvasRenderService.renderToBuffer({
Expand Down

0 comments on commit 20aef14

Please sign in to comment.