diff --git a/source/cli.js b/source/cli.js index ca419747..01c33807 100755 --- a/source/cli.js +++ b/source/cli.js @@ -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'); @@ -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 ? { diff --git a/source/npm-util.js b/source/npm-util.js index 84d7d793..cc76fe8f 100644 --- a/source/npm-util.js +++ b/source/npm-util.js @@ -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 () => { @@ -61,3 +62,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'; diff --git a/source/prerequisite-tasks.js b/source/prerequisite-tasks.js index 3309c763..a87a13a1 100644 --- a/source/prerequisite-tasks.js +++ b/source/prerequisite-tasks.js @@ -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 = [