Skip to content

Commit 7aa1bce

Browse files
authored
Merge pull request #122 from arethetypeswrong/bug/83
Don’t rely on `npm pack` STDOUT to get tarball filename
2 parents a8fe7a9 + 3cc28dc commit 7aa1bce

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

.changeset/giant-monkeys-sneeze.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@arethetypeswrong/cli": patch
3+
---
4+
5+
Fix `--pack` with pre/post scripts that write to STDOUT

packages/cli/src/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,13 @@ particularly ESM-related module resolution issues.`,
171171
}
172172
}
173173

174-
fileName = deleteTgz = path.resolve(
174+
const manifest = JSON.parse(await readFile(path.join(fileOrDirectory, "package.json"), { encoding: "utf8" }));
175+
fileName = deleteTgz = path.join(
175176
fileOrDirectory,
176-
execSync("npm pack", { cwd: fileOrDirectory, encoding: "utf8", stdio: "pipe" }).trim(),
177+
// https://github.com/npm/cli/blob/f875caa86900122819311dd77cde01c700fd1817/lib/utils/tar.js#L123-L125
178+
`${manifest.name.replace("@", "").replace("/", "-")}-${manifest.version}.tgz`,
177179
);
180+
execSync("npm pack", { cwd: fileOrDirectory, encoding: "utf8", stdio: "ignore" });
178181
}
179182
const file = await readFile(fileName);
180183
const data = new Uint8Array(file);

0 commit comments

Comments
 (0)