Skip to content

Commit

Permalink
chore: code review tidy + better error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
orangemug committed Nov 19, 2024
1 parent 210c39b commit 9d977ff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions scripts/dev/curriculum/_commands/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ describe("wrapHtmlLayout", () => {
describe("outputPathFromLabel", () => {
it("should work with valid label", () => {
expect(resolveInputPath(":foo")).toEqual(
`${process.cwd()}/scripts/dev/curriculum/output/screenshots/foo/`,
`${process.cwd()}/scripts/dev/curriculum/output/screenshots/foo`,
);
expect(resolveInputPath(":foo")).toEqual(
`${process.cwd()}/scripts/dev/curriculum/output/screenshots/foo/`,
`${process.cwd()}/scripts/dev/curriculum/output/screenshots/foo`,
);
});

Expand Down
7 changes: 4 additions & 3 deletions scripts/dev/curriculum/_commands/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { readFile, unlink } from "fs/promises";
import { join } from "path";

import { Page } from "puppeteer";
import sharp from "sharp";
Expand Down Expand Up @@ -91,7 +92,7 @@ export function wrapHtmlLayout(content: string) {
export function resolveInputPath(input: string) {
if (input.startsWith(":")) {
const labelName = input.replace(/^:/, "");
return `${BASE_PATH}/screenshots/${labelName}/`;
return join(BASE_PATH, "screenshots", labelName);
} else {
return input;
}
Expand All @@ -116,7 +117,7 @@ export function renderComparison(
after: Comparison | null,
) {
if (!before || !after) {
throw new Error("Missing");
throw new Error("Missing data, both comparison objects are empty");
}
const slug = before?.slug ?? after?.slug;

Expand Down Expand Up @@ -212,7 +213,7 @@ export async function screenshotPageCurrent(page: Page, path: string) {
}

if (images.length < 1) {
throw new Error("Missing");
throw new Error("Something went wrong, no images generated");
}

for (let i = 0; i < images.length; i++) {
Expand Down

0 comments on commit 9d977ff

Please sign in to comment.