chore(pack-verify): retain tarball on failure (fix dead cleanup flag)

Review follow-up: `cleanupTarball` was always true (set true at init and again
in the catch), so the finally guard was dead logic. Make it meaningful — retain
the packed tarball on failure so a packaging problem can be inspected, and log
where it is; the happy path still removes it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BrihGWcrM9JGRyu41nzZYw
This commit is contained in:
cliffhall 2026-07-10 18:25:10 -04:00
commit c1b168e522

View file

@ -151,6 +151,8 @@ console.log(
// runs the package's postinstall).
// ---------------------------------------------------------------------------
const work = mkdtempSync(join(tmpdir(), "pack-verify-"));
// Remove the packed tarball on success; retain it on failure so a packaging
// problem can be inspected (unpack it, diff the file list).
let cleanupTarball = true;
try {
ensureTestServer();
@ -253,7 +255,9 @@ try {
"web (prod / served dist), cli (stdio tools/list), and tui (help) end to end.",
);
} catch (err) {
cleanupTarball = true;
// Keep the tarball around for post-mortem inspection of the packaging failure.
cleanupTarball = false;
console.error(`pack:verify — tarball retained for inspection at ${tarball}`);
fail(err instanceof Error ? err.message : String(err));
} finally {
rmSync(work, { recursive: true, force: true });