Skip to content

Commit

Permalink
Fix name check for private registries (#356)
Browse files Browse the repository at this point in the history
This fixes the name check when publishing to a private registry by skipping it.

Fixes #350
Fixes #317
Closes #318
  • Loading branch information
itaisteinherz authored and sindresorhus committed Mar 15, 2019
1 parent 72ebf7d commit e8a3a7d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions source/cli.js
Expand Up @@ -6,7 +6,7 @@ const logSymbols = require('log-symbols');
const meow = require('meow');
const updateNotifier = require('update-notifier');
const hasYarn = require('has-yarn');
const npmName = require('npm-name');
const {isPackageNameAvailable} = require('./npm-util');
const version = require('./version');
const util = require('./util');
const ui = require('./ui');
Expand Down Expand Up @@ -73,7 +73,7 @@ process.on('SIGINT', () => {
(async () => {
const pkg = util.readPkg();

const isAvailable = cli.flags.publish ? await npmName(pkg.name) : false;
const isAvailable = cli.flags.publish ? await isPackageNameAvailable(pkg) : false;

const options = cli.input.length > 0 ?
{
Expand Down
12 changes: 12 additions & 0 deletions source/npm-util.js
Expand Up @@ -2,6 +2,7 @@
const execa = require('execa');
const pTimeout = require('p-timeout');
const ow = require('ow');
const npmName = require('npm-name');

exports.checkConnection = () => pTimeout(
(async () => {
Expand Down Expand Up @@ -67,3 +68,14 @@ exports.prereleaseTags = async packageName => {

return tags;
};

exports.isPackageNameAvailable = async pkg => {
const isExternalRegistry = exports.isExternalRegistry(pkg);
if (isExternalRegistry) {
return true;
}

return npmName(pkg.name);
};

exports.isExternalRegistry = pkg => typeof pkg.publishConfig === 'object' && typeof pkg.publishConfig.registry === 'string';
2 changes: 1 addition & 1 deletion source/prerequisite-tasks.js
Expand Up @@ -7,7 +7,7 @@ const npm = require('./npm-util');
const {getTagVersionPrefix} = require('./util');

module.exports = (input, pkg, options) => {
const isExternalRegistry = typeof pkg.publishConfig === 'object' && typeof pkg.publishConfig.registry === 'string';
const isExternalRegistry = npm.isExternalRegistry(pkg);
let newVersion = null;

const tasks = [
Expand Down

0 comments on commit e8a3a7d

Please sign in to comment.