From 03f47c13064d8a2b65d20ad4aa417057f9ddf9eb Mon Sep 17 00:00:00 2001 From: Mark Russell Date: Sat, 17 Oct 2026 13:30:11 -0400 Subject: [PATCH] pack.mjs: find the tarball by the new file, not by the JSON output of pnpm pnpm pack also prints the output of the package scripts that it starts (prepare, prepack), so the JSON parse failed for cue (release run 39053834123). The tarball is now the new .tgz file in the folder. Co-Authored-By: Claude Opus 5.5 --- scripts/release/pack.mjs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/scripts/release/pack.mjs b/scripts/release/pack.mjs index 62f95b3..aef2f8e 100644 --- a/scripts/release/pack.mjs +++ b/scripts/release/pack.mjs @@ -9,7 +9,7 @@ // specifier, because npm users cannot install that package. import { execFileSync } from "node:child_process"; -import { mkdirSync, writeFileSync } from "node:fs"; +import { mkdirSync, readdirSync, writeFileSync } from "node:fs"; import { basename, join, resolve } from "node:path"; import { publishedPackages, unpublishableDependencies } from "./workspace.mjs"; @@ -34,12 +34,13 @@ if (blocked.length > 0) { const shell = process.platform === "win32"; const lines = []; for (const { dir, manifest } of packages) { - const packed = execFileSync("pnpm", ["pack", "--json", "--pack-destination", resolve(out)], { - cwd: dir, - encoding: "utf8", - shell, - }); - const file = basename(JSON.parse(packed).filename); + // The new file in the folder is the tarball. The output of pnpm is not used: it also holds the + // output of the package scripts that pnpm pack starts (prepare, prepack). + const before = new Set(readdirSync(out)); + execFileSync("pnpm", ["pack", "--pack-destination", resolve(out)], { cwd: dir, stdio: ["ignore", "inherit", "inherit"], shell }); + const added = readdirSync(out).filter((name) => !before.has(name) && name.endsWith(".tgz")); + if (added.length !== 1) throw new Error(`pnpm pack of ${manifest.name} made ${added.length} tarballs: ${added.join(", ")}`); + const file = basename(added[0]); lines.push(`${manifest.name} ${manifest.version} ${file}`); process.stdout.write(`${manifest.name}@${manifest.version}: ${file}\n`); }