Merge pull request #186 from punker76/69-Proxy-support-for-extension-gallery

Proxy support for extensions #69
This commit is contained in:
João Moreno 2015-11-19 10:57:51 +01:00
commit bf35ff2159

View file

@ -20,6 +20,7 @@ import { download } from 'vs/base/node/request';
import { IWorkspaceContextService } from 'vs/workbench/services/workspace/common/contextService';
import { Limiter } from 'vs/base/common/async';
import Event, { Emitter } from 'vs/base/common/event';
import { manager as Settings } from 'vs/workbench/electron-main/settings';
function parseManifest(raw: string): TPromise<IExtensionManifest> {
return new Promise((c, e) => {
@ -115,12 +116,15 @@ export class ExtensionsService implements IExtensionsService {
return TPromise.wrapError(new Error(nls.localize('missingGalleryInformation', "Gallery information is missing")));
}
const httpProxySettings = Settings.getValue('http.proxy');
const getAgent = url => httpProxySettings ? getProxyAgent(url, httpProxySettings) : getSystemProxyAgent(url);
const url = `${ galleryInformation.galleryApiUrl }/publisher/${ extension.publisher }/extension/${ extension.name }/latest/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage?install=true`;
const zipPath = path.join(tmpdir(), galleryInformation.id);
const extensionPath = path.join(this.extensionsPath, `${ extension.publisher }.${ extension.name }`);
const manifestPath = path.join(extensionPath, 'package.json');
return download(zipPath, { url })
return download(zipPath, { url: url, agent: getAgent(url) })
.then(() => validate(zipPath, extension))
.then(manifest => { this._onInstallExtension.fire(manifest); return manifest; })
.then(manifest => extract(zipPath, extensionPath, { sourcePath: 'extension', overwrite: true }).then(() => manifest))