From 9d048b5c25a9cfa9b164657b5c67e1f9f8f3a523 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Sun, 10 Apr 2022 22:21:17 -0700 Subject: [PATCH] fix: show more information during publish dry-run Fixes #4317 --- lib/commands/publish.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) 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)) }