diff --git a/lib/commands/publish.js b/lib/commands/publish.js index 1f26370e89a56..560dae1b6f0e4 100644 --- a/lib/commands/publish.js +++ b/lib/commands/publish.js @@ -102,19 +102,20 @@ class Publish extends BaseCommand { logTar(pkgContents, { unicode }) } + const resolved = npa.resolve(manifest.name, manifest.version) + const registry = npmFetch.pickRegistry(resolved, opts) + const creds = this.npm.config.getCredentialsByURI(registry) + const outputRegistry = replaceInfo(registry) + if (!creds.token && !creds.username) { + throw Object.assign( + new Error(`This command requires you to be logged in to ${outputRegistry}`), { + code: 'ENEEDAUTH', + } + ) + } + log.notice('', `Publishing to ${outputRegistry}${dryRun ? ' (dry-run)' : ''}`) + if (!dryRun) { - const resolved = npa.resolve(manifest.name, manifest.version) - const registry = npmFetch.pickRegistry(resolved, opts) - const creds = this.npm.config.getCredentialsByURI(registry) - const outputRegistry = replaceInfo(registry) - if (!creds.token && !creds.username) { - throw Object.assign( - new Error(`This command requires you to be logged in to ${outputRegistry}`), { - code: 'ENEEDAUTH', - } - ) - } - log.notice('', `Publishing to ${outputRegistry}`) await otplease(opts, opts => libpub(manifest, tarballData, opts)) }