Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup! fix: show more information during publish dry-run
  • Loading branch information
lukekarrys committed Apr 11, 2022
commit bcb5b2876a4ccc6157ed963fdbc708b7460d71f2
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