test: improve npm pack invocation and assert no test files are packed

This commit is contained in:
pi
2026-04-11 02:05:23 +01:00
parent 11380ed49b
commit 4a51e7b0bc

View File

@@ -13,6 +13,8 @@ function getPackedPaths() {
const output = execFileSync("npm", ["pack", "--dry-run", "--json"], { const output = execFileSync("npm", ["pack", "--dry-run", "--json"], {
cwd: packageRoot, cwd: packageRoot,
encoding: "utf8", encoding: "utf8",
timeout: 30_000,
stdio: ["ignore", "pipe", "pipe"],
}); });
const [packResult] = JSON.parse(output) as Array<{ files: Array<{ path: string }> }>; const [packResult] = JSON.parse(output) as Array<{ files: Array<{ path: string }> }>;
return packResult.files.map((file) => file.path); return packResult.files.map((file) => file.path);
@@ -65,5 +67,5 @@ test("npm pack includes runtime package assets", () => {
assert.ok(packedPaths.includes("src/tools/write.ts")); assert.ok(packedPaths.includes("src/tools/write.ts"));
// Ensure test sources are not shipped // Ensure test sources are not shipped
assert.ok(!packedPaths.some((p) => p.endsWith(".test.ts"))); assert.deepEqual(packedPaths.filter((p) => p.endsWith(".test.ts")), []);
}); });