Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: npm publish --dry-run should not check login status #2422

Merged
merged 1 commit into from Jan 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 7 additions & 5 deletions lib/publish.js
Expand Up @@ -43,11 +43,13 @@ const publish = async args => {
})
}

const creds = npm.config.getCredentialsByURI(registry)
if (!creds.token && !creds.username) {
throw Object.assign(new Error('This command requires you to be logged in.'), {
code: 'ENEEDAUTH',
})
if (!opts.dryRun) {
const creds = npm.config.getCredentialsByURI(registry)
if (!creds.token && !creds.username) {
throw Object.assign(new Error('This command requires you to be logged in.'), {
code: 'ENEEDAUTH',
})
}
}

if (semver.validRange(defaultTag))
Expand Down
6 changes: 5 additions & 1 deletion test/lib/publish.js
Expand Up @@ -193,7 +193,11 @@ t.test('should log tarball contents', (t) => {
dryRun: true,
registry: 'https://registry.npmjs.org/',
},
config,
config: {
...config,
getCredentialsByURI: () => {
throw new Error('should not call getCredentialsByURI!')
}},
},
'../../lib/utils/tar.js': {
getContents: () => ({
Expand Down