// `script/projectname` is the single source of the project's name for every // script that needs one — `script/docker` builds its image tag from it, which // is the whole reason that file exists. Nothing checked that it agreed with // `package.json`, and after the repo was renamed it did not: the script still // said "quack", so `make docker` produced an image tagged after a name this // project has not used since May. // // The script is executed rather than read, because what matters is the string // it prints, not the source it prints it from. import { describe, expect, it } from "vitest"; import { execFileSync } from "node:child_process"; import { readFileSync } from "node:fs"; import { fileURLToPath } from "node:url"; import { join } from "node:path"; const repoRoot = fileURLToPath(new URL("../../", import.meta.url)); const pkg = JSON.parse( readFileSync(join(repoRoot, "package.json"), "utf-8"), ) as { name: string }; describe("script/projectname", () => { it("prints the name package.json declares", () => { const printed = execFileSync(join(repoRoot, "script/projectname"), { cwd: repoRoot, encoding: "utf-8", }).trim(); expect(printed).toBe(pkg.name); }); });