Skip to content

Commit

Permalink
Merge pull request #122 from arethetypeswrong/bug/83
Browse files Browse the repository at this point in the history
Don’t rely on `npm pack` STDOUT to get tarball filename
  • Loading branch information
andrewbranch authored Dec 3, 2023
2 parents a8fe7a9 + 3cc28dc commit 7aa1bce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/giant-monkeys-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@arethetypeswrong/cli": patch
---

Fix `--pack` with pre/post scripts that write to STDOUT
7 changes: 5 additions & 2 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7aa1bce

Please sign in to comment.