From 662a6e19209a30123327e4cc15ed550c6102ca2a Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Sun, 3 Dec 2023 10:26:13 -0800 Subject: [PATCH 1/2] =?UTF-8?q?Don=E2=80=99t=20rely=20on=20`npm=20pack`=20?= =?UTF-8?q?STDOUT=20to=20get=20tarball=20filename?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/cli/src/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 6a1df69..779e64b 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -171,10 +171,13 @@ particularly ESM-related module resolution issues.`, } } - fileName = deleteTgz = path.resolve( + const manifest = JSON.parse(await readFile(path.join(fileOrDirectory, "package.json"), { encoding: "utf8" })); + fileName = deleteTgz = path.join( fileOrDirectory, - execSync("npm pack", { cwd: fileOrDirectory, encoding: "utf8", stdio: "pipe" }).trim(), + // https://github.com/npm/cli/blob/f875caa86900122819311dd77cde01c700fd1817/lib/utils/tar.js#L123-L125 + `${manifest.name.replace("@", "").replace("/", "-")}-${manifest.version}.tgz`, ); + execSync("npm pack", { cwd: fileOrDirectory, encoding: "utf8", stdio: "ignore" }); } const file = await readFile(fileName); const data = new Uint8Array(file); From 3cc28dcaa33445556ae91ad2bd8ff522edae50e4 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Sun, 3 Dec 2023 10:30:37 -0800 Subject: [PATCH 2/2] Add changeset --- .changeset/giant-monkeys-sneeze.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/giant-monkeys-sneeze.md diff --git a/.changeset/giant-monkeys-sneeze.md b/.changeset/giant-monkeys-sneeze.md new file mode 100644 index 0000000..df24b4e --- /dev/null +++ b/.changeset/giant-monkeys-sneeze.md @@ -0,0 +1,5 @@ +--- +"@arethetypeswrong/cli": patch +--- + +Fix `--pack` with pre/post scripts that write to STDOUT