27 lines
950 B
TypeScript
27 lines
950 B
TypeScript
import { mkdtemp, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
import { describe, expect, test } from "vitest";
|
|
|
|
import { createReleaseArchive } from "../scripts/package-release-archive.mjs";
|
|
|
|
describe("package-release-archive", () => {
|
|
test("creates a zip archive with a top-level dist folder", async () => {
|
|
const tempDir = await mkdtemp(path.join(os.tmpdir(), "release-archive-"));
|
|
const sourceDir = path.join(tempDir, "source");
|
|
const archivePath = path.join(tempDir, "archive.zip");
|
|
|
|
await mkdir(sourceDir, { recursive: true });
|
|
await writeFile(path.join(sourceDir, "hello.txt"), "hello world", "utf8");
|
|
|
|
await createReleaseArchive({
|
|
archivePath,
|
|
sourceDir
|
|
});
|
|
|
|
const archive = await readFile(archivePath);
|
|
expect(archive.byteLength).toBeGreaterThan(0);
|
|
expect(archive.toString("utf8")).toContain("dist/hello.txt");
|
|
});
|
|
});
|