Skip to content

Commit

Permalink
Move to isExternalRegistry
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Jul 16, 2024
1 parent 0673248 commit ff7f87e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
7 changes: 1 addition & 6 deletions source/cli-implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,7 @@ async function getOptions() {

const packageManager = getPackageManagerConfig(rootDirectory, package_);

if (
packageManager.throwOnExternalRegistry
&& npm.isExternalRegistry(package_)
// NPM default registry https://github.com/npm/pneumatic-tubes/blob/1064fbb461464cc0fe18bd2790a176aa92bd63fd/index.js#L35
&& package_.publishConfig.registry !== 'https://registry.npmjs.org'
) {
if (packageManager.throwOnExternalRegistry && npm.isExternalRegistry(package_)) {
throw new Error(`External registry is not yet supported with ${packageManager.id}.`);
}

Expand Down
7 changes: 6 additions & 1 deletion source/npm/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ export const username = async ({externalRegistry}) => {
}
};

export const isExternalRegistry = package_ => typeof package_.publishConfig?.registry === 'string';
// NPM default registry https://github.com/npm/pneumatic-tubes/blob/1064fbb461464cc0fe18bd2790a176aa92bd63fd/index.js#L35
const NPM_DEFAULT_REGISTRY = 'https://registry.npmjs.org';
export const isExternalRegistry = package_ => {
const registry = package_.publishConfig?.registry;
return typeof registry === 'string' && registry !== NPM_DEFAULT_REGISTRY;
};

export const collaborators = async package_ => {
const packageName = package_.name;
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 @@ -7,4 +7,5 @@ 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'}}));
});

0 comments on commit ff7f87e

Please sign in to comment.