fix: handle npm 12 pack --json output in preview-packages

This commit is contained in:
David Brailovsky 2026-10-23 11:20:01 +02:00
parent 14c8118412
commit a1836b06c3

View file

@ -58,7 +58,9 @@ async function pack(argv) {
stdio: ["inherit", "pipe", "inherit"],
maxBuffer: 64 * 1024 * 1024,
});
const [info] = JSON.parse(output);
// npm 10/11 print an array, npm 12 prints an object keyed by package name.
const parsed = JSON.parse(output);
const info = Array.isArray(parsed) ? parsed[0] : Object.values(parsed)[0];
packed.push({ name: info.name, file: info.filename });
console.error(`packed ${info.name}@${info.version} -> ${info.filename}`);
} finally {