Skip to content

Commit 662a6e1

Browse files
committed
Don’t rely on npm pack STDOUT to get tarball filename
1 parent a8fe7a9 commit 662a6e1

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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)