Skip to content

Commit

Permalink
add proxy
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
badeggg authored and isaacs committed Sep 30, 2020
1 parent fef2646 commit 3b41705
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/utils/flat-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,13 @@ const flatOptions = npm => npm.flatOptions || Object.freeze({
...getScopesAndAuths(npm),

// npm fund exclusive option to select an item from a funding list
which: npm.config.get('which')
which: npm.config.get('which'),

// socks proxy can be configured in https-proxy or proxy field
// note that the various (HTTPS_|HTTP_|)PROXY environs will be
// respected if this is not set.
proxy: npm.config.get('https-proxy') || npm.config.get('proxy'),
noProxy: npm.config.get('noproxy')
})

const getPreferOnline = npm => {
Expand Down
2 changes: 2 additions & 0 deletions tap-snapshots/test-lib-utils-flat-options.js-TAP.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Object {
"metricsRegistry": "metrics-registry",
"nodeBin": "/path/to/some/node",
"nodeVersion": "1.2.3",
"noProxy": "noproxy",
"npmBin": "/path/to/npm/bin.js",
"npmCommand": null,
"npmSession": "12345",
Expand All @@ -83,6 +84,7 @@ Object {
"prefix": "/path/to/npm/cli",
"preid": "preid",
"projectScope": "@npmcli",
"proxy": "proxy",
"readOnly": "read-only",
"rebuildBundle": "rebuild-bundle",
"registry": "registry",
Expand Down
2 changes: 2 additions & 0 deletions test/lib/utils/flat-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ class MockConfig {
'user-agent': 'user-agent',
'@scope:registry': '@scope:registry',
'//nerf.dart:_authToken': '//nerf.dart:_authToken',
'proxy': 'proxy',
'noproxy': 'noproxy',
...opts
}]
}
Expand Down

0 comments on commit 3b41705

Please sign in to comment.