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

Add proxy #1859

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions docs/content/using-npm/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,9 @@ The string that starts all the debugging log output.
* Type: url

A proxy to use for outgoing https requests. If the `HTTPS_PROXY` or
`https_proxy` or `HTTP_PROXY` or `http_proxy` environment variables are set,
proxy settings will be honored by the underlying `request` library.
`https_proxy` environment variables are set, proxy settings will be honored
by the underlying `request` library. "npm config" prior to environment config.
You can set a socks server address in this field to use a socks proxy.

#### if-present

Expand Down Expand Up @@ -779,7 +780,7 @@ The node version to use when checking a package's `engines` map.
* Default: null
* Type: String or Array

A comma-separated string or an array of domain extensions that a proxy should not be used for.
A comma-separated string of domain extensions that a proxy should not be used for.

#### offline

Expand Down Expand Up @@ -914,9 +915,10 @@ Set to `false` to suppress the progress bar.
* Default: null
* Type: url

A proxy to use for outgoing http requests. If the `HTTP_PROXY` or
`http_proxy` environment variables are set, proxy settings will be
honored by the underlying `request` library.
A proxy to use for outgoing https requests. If the `HTTPS_PROXY` or
`https_proxy` environment variables are set, proxy settings will be honored
by the underlying `request` library. "npm config" prior to environment config.
You can set a socks server address in this field to use a socks proxy.

#### read-only

Expand Down
6 changes: 5 additions & 1 deletion lib/utils/flat-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,11 @@ 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 surely can be configured in https-proxy and proxy field
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 @@ -109,6 +109,8 @@ class MockConfig {
'user-agent': 'user-agent',
'@scope:registry': '@scope:registry',
'//nerf.dart:_authToken': '//nerf.dart:_authToken',
'proxy': 'proxy',
'noproxy': 'noproxy',
...opts
}]
}
Expand Down