Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

fix: Make sure, that proxy-related environment variables are passed to git… #1122

Merged
merged 1 commit into from
Jun 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion plugins/workspace-plugin/src/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export async function execute(
options.env = mergeProcessEnv(options.env);
}

const command = spawn(commandLine, args, options);
const command = spawn(commandLine, args, withProxySettings(options));

let result = '';
let error = '';
Expand Down Expand Up @@ -90,3 +90,31 @@ function mergeProcessEnv(env: NodeJS.ProcessEnv | undefined): NodeJS.ProcessEnv

return env;
}

function withProxySettings(options?: SpawnOptionsWithoutStdio): SpawnOptionsWithoutStdio {
const HTTP_PROXY = 'http_proxy';
const HTTPS_PROXY = 'https_proxy';
const NO_PROXY = 'no_proxy';

if (!options) {
options = {};
}

if (!options.env) {
options.env = {};
}

if (process.env[HTTP_PROXY]) {
options.env.HTTP_PROXY = process.env[HTTP_PROXY];
}

if (process.env[HTTPS_PROXY]) {
options.env.HTTPS_PROXY = process.env[HTTPS_PROXY];
}

if (process.env[NO_PROXY]) {
options.env.NO_PROXY = process.env[NO_PROXY];
}

return options;
}