Skip to content

Commit

Permalink
Pass full set of options to login helper functions
Browse files Browse the repository at this point in the history
This fixes 'npm login --no-strict-ssl', as well as a host of other
options that one might want to set while logging in.

Reported by: @toddself
  • Loading branch information
isaacs committed Dec 18, 2020
1 parent b98569a commit 9eef638
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
1 change: 1 addition & 0 deletions lib/adduser.js
Expand Up @@ -59,6 +59,7 @@ const adduser = async (args) => {
log.notice('', `Log in on ${replaceInfo(registry)}`)

const { message, newCreds } = await auth({
...npm.flatOptions,
creds,
registry,
scope,
Expand Down
24 changes: 15 additions & 9 deletions test/lib/adduser.js
Expand Up @@ -9,21 +9,27 @@ const _flatOptions = {
authType: 'legacy',
registry: 'https://registry.npmjs.org/',
scope: '',
fromFlatOptions: true,
}

let failSave = false
let deletedConfig = {}
let registryOutput = ''
let setConfig = {}
const authDummy = () => Promise.resolve({
message: 'success',
newCreds: {
username: 'u',
password: 'p',
email: 'u@npmjs.org',
alwaysAuth: false,
},
})
const authDummy = (options) => {
if (!options.fromFlatOptions)
throw new Error('did not pass full flatOptions to auth function')

return Promise.resolve({
message: 'success',
newCreds: {
username: 'u',
password: 'p',
email: 'u@npmjs.org',
alwaysAuth: false,
},
})
}

const deleteMock = (key, where) => {
deletedConfig = {
Expand Down

0 comments on commit 9eef638

Please sign in to comment.