forked from microsoft/os-proxy-resolver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
40 lines (34 loc) · 1.31 KB
/
Copy pathindex.js
File metadata and controls
40 lines (34 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'use strict';
const { getPlatformPackage } = require('./platform');
const packages = {
'darwin-arm64': '@vscode/os-proxy-resolver-darwin-arm64',
'darwin-x64': '@vscode/os-proxy-resolver-darwin-x64',
'linux-arm-glibc': '@vscode/os-proxy-resolver-linux-arm-gnueabihf',
'linux-arm64-glibc': '@vscode/os-proxy-resolver-linux-arm64-gnu',
'linux-arm64-musl': '@vscode/os-proxy-resolver-linux-arm64-musl',
'linux-x64-glibc': '@vscode/os-proxy-resolver-linux-x64-gnu',
'linux-x64-musl': '@vscode/os-proxy-resolver-linux-x64-musl',
'win32-arm64': '@vscode/os-proxy-resolver-win32-arm64-msvc',
'win32-x64': '@vscode/os-proxy-resolver-win32-x64-msvc',
};
const platform = getPlatformPackage();
const packageName = packages[platform];
if (!packageName) {
throw new Error(`@vscode/os-proxy-resolver does not support ${platform}`);
}
try {
require.resolve(packageName);
} catch (error) {
if (error && error.code === 'MODULE_NOT_FOUND') {
throw new Error(
`The native package ${packageName} is not installed. ` +
'Ensure optional dependencies are enabled and npm_config_arch matches the target architecture.',
{ cause: error }
);
}
throw error;
}
const binding = require(packageName);
exports.ProxyResolver = binding.ProxyResolver;
exports.resolveProxy = binding.resolveProxy;
exports.readProxyConfig = binding.readProxyConfig;