Skip to content

Commit 0f5dd33

Browse files
authored
Fix npm 9 compatibility (#666)
1 parent 95622c0 commit 0f5dd33

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

source/npm/util.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const pkgDir = require('pkg-dir');
1010
const ignoreWalker = require('ignore-walk');
1111
const minimatch = require('minimatch');
1212
const {verifyRequirementSatisfied} = require('../version');
13+
const semver = require('semver');
1314

1415
// According to https://docs.npmjs.com/files/package.json#files
1516
// npm's default behavior is to ignore these files.
@@ -68,7 +69,8 @@ exports.collaborators = async pkg => {
6869
const packageName = pkg.name;
6970
ow(packageName, ow.string);
7071

71-
const args = ['access', 'ls-collaborators', packageName];
72+
const npmVersion = await exports.version();
73+
const args = semver.satisfies(npmVersion, '>=9.0.0') ? ['access', 'list', 'collaborators', packageName, '--json'] : ['access', 'ls-collaborators', packageName];
7274
if (exports.isExternalRegistry(pkg)) {
7375
args.push('--registry', pkg.publishConfig.registry);
7476
}

0 commit comments

Comments
 (0)