Skip to content

Commit

Permalink
fixup! fix: show more information during publish dry-run
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys authored and fritzy committed Apr 13, 2022
1 parent 5ba7f0c commit 2545065
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/commands/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 2545065

Please sign in to comment.