Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow publishConfig.registry to be npm default registry when using Yarn berry #750

Merged
merged 4 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion source/npm/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,16 @@ export const username = async ({externalRegistry}) => {
}
};

export const isExternalRegistry = package_ => typeof package_.publishConfig?.registry === 'string';
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/',
]);
export const isExternalRegistry = package_ => {
const registry = package_.publishConfig?.registry;
return typeof registry === 'string' && !NPM_DEFAULT_REGISTRIES.has(registry);
};

export const collaborators = async package_ => {
const packageName = package_.name;
Expand Down
2 changes: 2 additions & 0 deletions test/npm/util/is-external-registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ test('main', t => {
t.false(npm.isExternalRegistry({name: 'foo'}));
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/'}}));
});