mirror of
https://github.com/earendil-works/pi.git
synced 2026-09-28 05:54:43 +08:00
fix: handle npm 12 pack --json object output in local release script
npm 12 returns an object keyed by package name instead of an array, which broke packPackage with a TypeError.
This commit is contained in:
@@ -195,7 +195,9 @@ function packPackage(pkg, tarballDirectory) {
|
||||
capture: true,
|
||||
cwd: pkg.directory,
|
||||
});
|
||||
const packed = JSON.parse(output)[0];
|
||||
// npm <11.6 returns an array; newer npm returns an object keyed by package name.
|
||||
const parsed = JSON.parse(output);
|
||||
const packed = Array.isArray(parsed) ? parsed[0] : Object.values(parsed)[0];
|
||||
return join(tarballDirectory, packed.filename);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user