UNPKG

842 BJavaScriptView Raw
1import * as debug from 'debug';
2const d = debug('@electron/get:proxy');
3/**
4 * Initializes a third-party proxy module for HTTP(S) requests.
5 */
6export function initializeProxy() {
7 try {
8 // Code originally from https://github.com/yeoman/yo/blob/b2eea87e/lib/cli.js#L19-L28
9 const MAJOR_NODEJS_VERSION = parseInt(process.version.slice(1).split('.')[0], 10);
10 if (MAJOR_NODEJS_VERSION >= 10) {
11 // `global-agent` works with Node.js v10 and above.
12 require('global-agent').bootstrap();
13 }
14 else {
15 // `global-tunnel-ng` works with Node.js v10 and below.
16 require('global-tunnel-ng').initialize();
17 }
18 }
19 catch (e) {
20 d('Could not load either proxy modules, built-in proxy support not available:', e);
21 }
22}
23//# sourceMappingURL=proxy.js.map
\No newline at end of file