Skip to content

Commit

Permalink
Allow both
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Jul 16, 2024
1 parent ff7f87e commit 6bbf3df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 7 additions & 3 deletions source/npm/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,15 @@ export const username = async ({externalRegistry}) => {
}
};

// NPM default registry https://github.com/npm/pneumatic-tubes/blob/1064fbb461464cc0fe18bd2790a176aa92bd63fd/index.js#L35
const NPM_DEFAULT_REGISTRY = 'https://registry.npmjs.org';
const NPM_DEFAULT_REGISTRIES = new Set([
// https://docs.npmjs.com/cli/v10/using-npm/registry
'https://registry.npmjs.org',
// https://docs.npmjs.com/cli/v10/commands/npm-profile#registry
'https://registry.npmjs.org/'

Check failure on line 50 in source/npm/util.js

View workflow job for this annotation

GitHub Actions / Node.js 21

Missing trailing comma.

Check failure on line 50 in source/npm/util.js

View workflow job for this annotation

GitHub Actions / Node.js 20

Missing trailing comma.

Check failure on line 50 in source/npm/util.js

View workflow job for this annotation

GitHub Actions / Node.js 18

Missing trailing comma.
]);
export const isExternalRegistry = package_ => {
const registry = package_.publishConfig?.registry;
return typeof registry === 'string' && registry !== NPM_DEFAULT_REGISTRY;
return typeof registry === 'string' && !NPM_DEFAULT_REGISTRIES.has(registry);
};

export const collaborators = async package_ => {
Expand Down
1 change: 1 addition & 0 deletions test/npm/util/is-external-registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ test('main', t => {
t.false(npm.isExternalRegistry({publishConfig: {registry: true}}));
t.false(npm.isExternalRegistry({publishConfig: 'not an object'}));
t.false(npm.isExternalRegistry({publishConfig: {registry: 'https://registry.npmjs.org'}}));
t.false(npm.isExternalRegistry({publishConfig: {registry: 'https://registry.npmjs.org/'}}));
});

0 comments on commit 6bbf3df

Please sign in to comment.