diff options
author | dr-js <dr@dr.run> | 2021-01-08 04:46:57 +0300 |
---|---|---|
committer | nlf <quitlahok@gmail.com> | 2021-01-28 23:30:16 +0300 |
commit | 938a77d6e7fb79f8ceb72c51bf06e27127fb9f06 (patch) | |
tree | 2eb81688ab8fb96514e11e6f2f510d31979d8371 | |
parent | f1bea2f09e283f994bd8b69a356cbe11559c8c1f (diff) |
fix: publish: delay registry & login check till publishConfig merge
-rw-r--r-- | lib/publish.js | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/lib/publish.js b/lib/publish.js index 8ef7eff4c..49b208807 100644 --- a/lib/publish.js +++ b/lib/publish.js @@ -35,22 +35,7 @@ const publish = async args => { log.verbose('publish', args) const opts = { ...npm.flatOptions } - const { json, defaultTag, registry } = opts - - if (!registry) { - throw Object.assign(new Error('No registry specified.'), { - code: 'ENOREGISTRY', - }) - } - - if (!opts.dryRun) { - const creds = npm.config.getCredentialsByURI(registry) - if (!creds.token && !creds.username) { - throw Object.assign(new Error('This command requires you to be logged in.'), { - code: 'ENEEDAUTH', - }) - } - } + const { json, defaultTag } = opts if (semver.validRange(defaultTag)) throw new Error('Tag name must not be a valid SemVer range: ' + defaultTag.trim()) @@ -91,6 +76,22 @@ const publish_ = async (arg, opts) => { if (manifest.publishConfig) Object.assign(opts, publishConfigToOpts(manifest.publishConfig)) + const { registry } = opts + if (!registry) { + throw Object.assign(new Error('No registry specified.'), { + code: 'ENOREGISTRY', + }) + } + + if (!dryRun) { + const creds = npm.config.getCredentialsByURI(registry) + if (!creds.token && !creds.username) { + throw Object.assign(new Error('This command requires you to be logged in.'), { + code: 'ENEEDAUTH', + }) + } + } + // only run scripts for directory type publishes if (spec.type === 'directory') { await runScript({ |