UNPKG

1.35 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const debug = require("debug");
4const utils_1 = require("./utils");
5const d = debug('@electron/get:proxy');
6/**
7 * Initializes a third-party proxy module for HTTP(S) requests.
8 */
9function initializeProxy() {
10 try {
11 // Code originally from https://github.com/yeoman/yo/blob/b2eea87e/lib/cli.js#L19-L28
12 const MAJOR_NODEJS_VERSION = parseInt(process.version.slice(1).split('.')[0], 10);
13 if (MAJOR_NODEJS_VERSION >= 10) {
14 // See: https://github.com/electron/get/pull/214#discussion_r798845713
15 const env = utils_1.getEnv('GLOBAL_AGENT_');
16 utils_1.setEnv('GLOBAL_AGENT_HTTP_PROXY', env('HTTP_PROXY'));
17 utils_1.setEnv('GLOBAL_AGENT_HTTPS_PROXY', env('HTTPS_PROXY'));
18 utils_1.setEnv('GLOBAL_AGENT_NO_PROXY', env('NO_PROXY'));
19 // `global-agent` works with Node.js v10 and above.
20 require('global-agent').bootstrap();
21 }
22 else {
23 // `global-tunnel-ng` works with Node.js v10 and below.
24 require('global-tunnel-ng').initialize();
25 }
26 }
27 catch (e) {
28 d('Could not load either proxy modules, built-in proxy support not available:', e);
29 }
30}
31exports.initializeProxy = initializeProxy;
32//# sourceMappingURL=proxy.js.map
\No newline at end of file