Skip to content

Commit 6c5eee3

Browse files
authored
Allow publishConfig.registry to be npm default registry when using Yarn berry (#750)
1 parent a9e8fc7 commit 6c5eee3

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

source/npm/util.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,16 @@ export const username = async ({externalRegistry}) => {
4343
}
4444
};
4545

46-
export const isExternalRegistry = package_ => typeof package_.publishConfig?.registry === 'string';
46+
const NPM_DEFAULT_REGISTRIES = new Set([
47+
// https://docs.npmjs.com/cli/v10/using-npm/registry
48+
'https://registry.npmjs.org',
49+
// https://docs.npmjs.com/cli/v10/commands/npm-profile#registry
50+
'https://registry.npmjs.org/',
51+
]);
52+
export const isExternalRegistry = package_ => {
53+
const registry = package_.publishConfig?.registry;
54+
return typeof registry === 'string' && !NPM_DEFAULT_REGISTRIES.has(registry);
55+
};
4756

4857
export const collaborators = async package_ => {
4958
const packageName = package_.name;

test/npm/util/is-external-registry.js

+2
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ test('main', t => {
77
t.false(npm.isExternalRegistry({name: 'foo'}));
88
t.false(npm.isExternalRegistry({publishConfig: {registry: true}}));
99
t.false(npm.isExternalRegistry({publishConfig: 'not an object'}));
10+
t.false(npm.isExternalRegistry({publishConfig: {registry: 'https://registry.npmjs.org'}}));
11+
t.false(npm.isExternalRegistry({publishConfig: {registry: 'https://registry.npmjs.org/'}}));
1012
});

0 commit comments

Comments
 (0)