Skip to content

Commit 9eef638

Browse files
committed
Pass full set of options to login helper functions
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
1 parent b98569a commit 9eef638

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

lib/adduser.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const adduser = async (args) => {
5959
log.notice('', `Log in on ${replaceInfo(registry)}`)
6060

6161
const { message, newCreds } = await auth({
62+
...npm.flatOptions,
6263
creds,
6364
registry,
6465
scope,

test/lib/adduser.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,27 @@ const _flatOptions = {
99
authType: 'legacy',
1010
registry: 'https://registry.npmjs.org/',
1111
scope: '',
12+
fromFlatOptions: true,
1213
}
1314

1415
let failSave = false
1516
let deletedConfig = {}
1617
let registryOutput = ''
1718
let setConfig = {}
18-
const authDummy = () => Promise.resolve({
19-
message: 'success',
20-
newCreds: {
21-
username: 'u',
22-
password: 'p',
23-
24-
alwaysAuth: false,
25-
},
26-
})
19+
const authDummy = (options) => {
20+
if (!options.fromFlatOptions)
21+
throw new Error('did not pass full flatOptions to auth function')
22+
23+
return Promise.resolve({
24+
message: 'success',
25+
newCreds: {
26+
username: 'u',
27+
password: 'p',
28+
29+
alwaysAuth: false,
30+
},
31+
})
32+
}
2733

2834
const deleteMock = (key, where) => {
2935
deletedConfig = {

0 commit comments

Comments
 (0)