Skip to content

Commit

Permalink
fix: show more information during publish dry-run
Browse files Browse the repository at this point in the history
Fixes #4317
  • Loading branch information
lukekarrys committed Apr 11, 2022
1 parent 1617bce commit 9d048b5
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions lib/commands/publish.js
Expand Up @@ -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))
}

Expand Down

0 comments on commit 9d048b5

Please sign in to comment.