Skip to content

Commit cba004d

Browse files
committed
chore!(backend-shared): Remove deprecated npm proxy settings
# Conflicts: # packages/cubejs-backend-shared/package.json
1 parent ecf72c8 commit cba004d

File tree

2 files changed

+2
-43
lines changed

2 files changed

+2
-43
lines changed

packages/cubejs-backend-shared/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
"decompress": "^4.2.1",
4343
"env-var": "^6.3.0",
4444
"fs-extra": "^9.1.0",
45-
"https-proxy-agent": "^7.0.6",
4645
"lru-cache": "^11.1.0",
4746
"moment-range": "^4.0.2",
4847
"moment-timezone": "^0.5.47",
Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,8 @@
1-
import { exec } from 'child_process';
21
import { ProxyAgent } from 'proxy-agent';
3-
import { HttpsProxyAgent } from 'https-proxy-agent';
4-
5-
let npmProxy: string;
6-
let npmProxyInitialized = false;
7-
8-
function getCommandOutput(command: string) {
9-
return new Promise<string>((resolve, reject) => {
10-
exec(command, (error, stdout) => {
11-
if (error) {
12-
reject(error.message);
13-
return;
14-
}
15-
16-
resolve(stdout);
17-
});
18-
});
19-
}
20-
21-
/**
22-
* @deprecated
23-
* use ProxyAgent instead
24-
*/
25-
export async function getProxySettings(): Promise<string> {
26-
const [proxy] = (
27-
await Promise.all([getCommandOutput('npm config -g get https-proxy'), getCommandOutput('npm config -g get proxy')])
28-
)
29-
.map((s) => s.trim())
30-
.filter((s) => !['null', 'undefined', ''].includes(s));
31-
32-
npmProxyInitialized = true;
33-
34-
return proxy;
35-
}
362

373
export async function getHttpAgentForProxySettings() {
38-
if (!npmProxyInitialized) {
39-
npmProxy = await getProxySettings();
4+
if (!process.env.HTTP_PROXY && !process.env.HTTPS_PROXY) {
5+
return undefined;
406
}
41-
42-
if (npmProxy) {
43-
console.warn('Npm proxy settings are deprecated. Please use HTTP_PROXY, HTTPS_PROXY environment variables instead.');
44-
return new HttpsProxyAgent(npmProxy);
45-
}
46-
477
return new ProxyAgent();
488
}

0 commit comments

Comments
 (0)