diff --git a/lib/utils/flat-options.js b/lib/utils/flat-options.js index 54ba22d6c8ffb..721bbbde76651 100644 --- a/lib/utils/flat-options.js +++ b/lib/utils/flat-options.js @@ -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 => { diff --git a/tap-snapshots/test-lib-utils-flat-options.js-TAP.test.js b/tap-snapshots/test-lib-utils-flat-options.js-TAP.test.js index 0e7b7c33e6c92..cd41d33cbb26c 100644 --- a/tap-snapshots/test-lib-utils-flat-options.js-TAP.test.js +++ b/tap-snapshots/test-lib-utils-flat-options.js-TAP.test.js @@ -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", @@ -83,6 +84,7 @@ Object { "prefix": "/path/to/npm/cli", "preid": "preid", "projectScope": "@npmcli", + "proxy": "proxy", "readOnly": "read-only", "rebuildBundle": "rebuild-bundle", "registry": "registry", diff --git a/test/lib/utils/flat-options.js b/test/lib/utils/flat-options.js index 162e698daf29e..f18ce828c3e1d 100644 --- a/test/lib/utils/flat-options.js +++ b/test/lib/utils/flat-options.js @@ -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 }] }