From 25450652240dc8e7e28e391313b93f0f27c6da19 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Mon, 11 Apr 2022 11:58:18 -0700 Subject: [PATCH] fixup! fix: show more information during publish dry-run --- lib/commands/publish.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/commands/publish.js b/lib/commands/publish.js index 560dae1b6f0e4..51861c5aa3554 100644 --- a/lib/commands/publish.js +++ b/lib/commands/publish.js @@ -105,14 +105,18 @@ class Publish extends BaseCommand { const resolved = npa.resolve(manifest.name, manifest.version) const registry = npmFetch.pickRegistry(resolved, opts) const creds = this.npm.config.getCredentialsByURI(registry) + const noCreds = !creds.token && !creds.username 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', - } - ) + + if (noCreds) { + const msg = `This command requires you to be logged in to ${outputRegistry}` + if (dryRun) { + log.warn('', `${msg} (dry-run)`) + } else { + throw Object.assign(new Error(msg), { code: 'ENEEDAUTH' }) + } } + log.notice('', `Publishing to ${outputRegistry}${dryRun ? ' (dry-run)' : ''}`) if (!dryRun) {