
























@@ -188,20 +188,28 @@ export function collectPluginNpmPublishedRuntimeErrors(params) {
188188return errors;
189189}
190190191+export function resolveNpmPackFilename(output) {
192+const filename = output
193+.split(/\r?\n/u)
194+.map((line) => line.trim())
195+.filter(Boolean)
196+.at(-1);
197+if (typeof filename !== "string" || !filename.endsWith(".tgz")) {
198+throw new Error(`npm pack did not report a tarball filename`);
199+}
200+return filename;
201+}
202+191203function npmPack(spec, destinationDir) {
192204const output = execFileSync(
193205"npm",
194-["pack", spec, "--json", "--ignore-scripts", "--pack-destination", destinationDir],
206+["pack", spec, "--ignore-scripts", "--pack-destination", destinationDir],
195207{
196208encoding: "utf8",
197209stdio: ["ignore", "pipe", "pipe"],
198210},
199211);
200-const rows = JSON.parse(output);
201-const filename = rows?.[0]?.filename;
202-if (typeof filename !== "string" || !filename) {
203-throw new Error(`npm pack ${spec} did not report a tarball filename`);
204-}
212+const filename = resolveNpmPackFilename(output);
205213return path.isAbsolute(filename) ? filename : path.join(destinationDir, filename);
206214}
207215此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。