070959e133
landing-page-staging / Deploy landing page to staging (push) Has been skipped
landing-page-ci / Validate landing page (push) Failing after 4s
visual-baseline / Capture visual baselines (push) Has been cancelled
bake-plugin-previews / Bake plugin previews (push) Has been cancelled
28 lines
1.2 KiB
TypeScript
28 lines
1.2 KiB
TypeScript
import { mkdir, mkdtemp, writeFile, rm } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
import { hashPackageSourcePath } from "../src/package-source-hash.js";
|
|
|
|
describe("hashPackageSourcePath", () => {
|
|
it("includes package versions in the source hash", async () => {
|
|
const root = await mkdtemp(join(tmpdir(), "open-design-package-source-hash-"));
|
|
const packageRoot = join(root, "apps", "packaged");
|
|
try {
|
|
await mkdir(join(packageRoot, "src"), { recursive: true });
|
|
await writeFile(join(packageRoot, "src", "index.ts"), "export const value = 1;\n", "utf8");
|
|
await writeFile(join(packageRoot, "package.json"), `${JSON.stringify({ name: "@open-design/packaged", version: "1.0.0" }, null, 2)}\n`, "utf8");
|
|
const firstHash = await hashPackageSourcePath(packageRoot);
|
|
|
|
await writeFile(join(packageRoot, "package.json"), `${JSON.stringify({ name: "@open-design/packaged", version: "1.0.1" }, null, 2)}\n`, "utf8");
|
|
const secondHash = await hashPackageSourcePath(packageRoot);
|
|
|
|
expect(secondHash).not.toBe(firstHash);
|
|
} finally {
|
|
await rm(root, { force: true, recursive: true });
|
|
}
|
|
});
|
|
});
|