Skip to content

Commit

Permalink
Merge pull request #216 from snyk/fix/HEAD-674_restore_system_proxy
Browse files Browse the repository at this point in the history
fix: restore system proxy
  • Loading branch information
dotkas authored Sep 10, 2023
2 parents a507862 + 475b4f9 commit 08ffde3
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/dependencies/sub-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,29 @@ interface ProcessOptions {
}

function makeSpawnOptions(options?: ProcessOptions) {
const spawnOptions: SpawnOptions = { shell: true };
const spawnOptions: SpawnOptions = {
shell: true,
env: { ...process.env },
};
if (options && options.cwd) {
spawnOptions.cwd = options.cwd;
}
if (options && options.env) {
spawnOptions.env = options.env;
}

// Before spawning an external process, we look if we need to restore the system proxy configuration,
// which overides the cli internal proxy configuration.
if (process.env.SNYK_SYSTEM_HTTP_PROXY !== undefined) {
spawnOptions.env.HTTP_PROXY = process.env.SNYK_SYSTEM_HTTP_PROXY;
}
if (process.env.SNYK_SYSTEM_HTTPS_PROXY !== undefined) {
spawnOptions.env.HTTPS_PROXY = process.env.SNYK_SYSTEM_HTTPS_PROXY;
}
if (process.env.SNYK_SYSTEM_NO_PROXY !== undefined) {
spawnOptions.env.NO_PROXY = process.env.SNYK_SYSTEM_NO_PROXY;
}

return spawnOptions;
}

Expand Down

0 comments on commit 08ffde3

Please sign in to comment.