From bcb1e2aa62864bce1150b551ed9aac29e318fb02 Mon Sep 17 00:00:00 2001 From: Yuwei Ba Date: Fri, 30 Dec 2016 09:00:55 +0800 Subject: [PATCH] Add support for reading http.proxy setting (#639) * Add support for reading http.proxy setting * fix proxy config 1. set both lower and upper case proxy environment variable 2. do not touch process.env when http.proxy setting is not present --- src/goInstallTools.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/goInstallTools.ts b/src/goInstallTools.ts index 9164830cb..ce4208b2e 100644 --- a/src/goInstallTools.ts +++ b/src/goInstallTools.ts @@ -115,9 +115,20 @@ function installTools(goVersion: SemVersion, missing?: string[]) { outputChannel.appendLine(''); // Blank line for spacing. + // http.proxy setting takes precedence over environment variables + let httpProxy = vscode.workspace.getConfiguration('http').get('proxy'); + let env = process.env; + if (httpProxy) { + env = Object.assign({}, process.env, { + http_proxy: httpProxy, + HTTP_PROXY: httpProxy, + https_proxy: httpProxy, + HTTPS_PROXY: httpProxy, + }); + } missing.reduce((res: Promise, tool: string) => { return res.then(sofar => new Promise((resolve, reject) => { - cp.execFile(goRuntimePath, ['get', '-u', '-v', tools[tool]], { env: process.env }, (err, stdout, stderr) => { + cp.execFile(goRuntimePath, ['get', '-u', '-v', tools[tool]], { env }, (err, stdout, stderr) => { if (err) { outputChannel.appendLine('Installing ' + tool + ' FAILED'); let failureReason = tool + ';;' + err + stdout.toString() + stderr.toString();