Skip to content

Commit 3b41705

Browse files
badegggisaacs
authored andcommitted
add proxy
PR-URL: #1859 Credit: @badeggg Close: #1859 Reviewed-by: @isaacs EDIT: changed flatOptions.noproxy to flatOptions.noProxy, since make-fetch-happen reads it from the camel-cased property.
1 parent fef2646 commit 3b41705

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

lib/utils/flat-options.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,13 @@ const flatOptions = npm => npm.flatOptions || Object.freeze({
209209
...getScopesAndAuths(npm),
210210

211211
// npm fund exclusive option to select an item from a funding list
212-
which: npm.config.get('which')
212+
which: npm.config.get('which'),
213+
214+
// socks proxy can be configured in https-proxy or proxy field
215+
// note that the various (HTTPS_|HTTP_|)PROXY environs will be
216+
// respected if this is not set.
217+
proxy: npm.config.get('https-proxy') || npm.config.get('proxy'),
218+
noProxy: npm.config.get('noproxy')
213219
})
214220

215221
const getPreferOnline = npm => {

tap-snapshots/test-lib-utils-flat-options.js-TAP.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ Object {
6666
"metricsRegistry": "metrics-registry",
6767
"nodeBin": "/path/to/some/node",
6868
"nodeVersion": "1.2.3",
69+
"noProxy": "noproxy",
6970
"npmBin": "/path/to/npm/bin.js",
7071
"npmCommand": null,
7172
"npmSession": "12345",
@@ -83,6 +84,7 @@ Object {
8384
"prefix": "/path/to/npm/cli",
8485
"preid": "preid",
8586
"projectScope": "@npmcli",
87+
"proxy": "proxy",
8688
"readOnly": "read-only",
8789
"rebuildBundle": "rebuild-bundle",
8890
"registry": "registry",

test/lib/utils/flat-options.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ class MockConfig {
110110
'user-agent': 'user-agent',
111111
'@scope:registry': '@scope:registry',
112112
'//nerf.dart:_authToken': '//nerf.dart:_authToken',
113+
'proxy': 'proxy',
114+
'noproxy': 'noproxy',
113115
...opts
114116
}]
115117
}

0 commit comments

Comments
 (0)