Skip to content

Commit 08ffde3

Browse files
authored
Merge pull request #216 from snyk/fix/HEAD-674_restore_system_proxy
fix: restore system proxy
2 parents a507862 + 475b4f9 commit 08ffde3

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

lib/dependencies/sub-process.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,29 @@ interface ProcessOptions {
77
}
88

99
function makeSpawnOptions(options?: ProcessOptions) {
10-
const spawnOptions: SpawnOptions = { shell: true };
10+
const spawnOptions: SpawnOptions = {
11+
shell: true,
12+
env: { ...process.env },
13+
};
1114
if (options && options.cwd) {
1215
spawnOptions.cwd = options.cwd;
1316
}
1417
if (options && options.env) {
1518
spawnOptions.env = options.env;
1619
}
20+
21+
// Before spawning an external process, we look if we need to restore the system proxy configuration,
22+
// which overides the cli internal proxy configuration.
23+
if (process.env.SNYK_SYSTEM_HTTP_PROXY !== undefined) {
24+
spawnOptions.env.HTTP_PROXY = process.env.SNYK_SYSTEM_HTTP_PROXY;
25+
}
26+
if (process.env.SNYK_SYSTEM_HTTPS_PROXY !== undefined) {
27+
spawnOptions.env.HTTPS_PROXY = process.env.SNYK_SYSTEM_HTTPS_PROXY;
28+
}
29+
if (process.env.SNYK_SYSTEM_NO_PROXY !== undefined) {
30+
spawnOptions.env.NO_PROXY = process.env.SNYK_SYSTEM_NO_PROXY;
31+
}
32+
1733
return spawnOptions;
1834
}
1935

0 commit comments

Comments
 (0)