From a631525fbb1bc0798104ecf6fb54cbda56d1409d Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Fri, 13 May 2016 18:49:43 -0700 Subject: [PATCH] Have --install-extension exit earlier if already installed Fixes #6364 --- src/vs/code/node/cliProcessMain.ts | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/vs/code/node/cliProcessMain.ts b/src/vs/code/node/cliProcessMain.ts index c98f1167632..a25fc9012a2 100644 --- a/src/vs/code/node/cliProcessMain.ts +++ b/src/vs/code/node/cliProcessMain.ts @@ -59,19 +59,20 @@ class Main { } private installExtension(ids: string[]): TPromise { - return sequence(ids.map(id => () => { - return this.extensionGalleryService.query({ ids: [id] }).then(result => { - const [extension] = result.firstPage; + return this.extensionManagementService.getInstalled().then(installed => { + return sequence(ids.map(id => () => { - if (!extension) { - return TPromise.wrapError(`${ notFound(id) }\n${ useId }`); + const isInstalled = installed.some(e => getExtensionId(e) === id); + + if (isInstalled) { + return TPromise.wrapError(localize('alreadyInstalled', "Extension '{0}' is already installed.", id)); } - return this.extensionManagementService.getInstalled().then(installed => { - const isInstalled = installed.some(e => getExtensionId(e) === id); + return this.extensionGalleryService.query({ ids: [id] }).then(result => { + const [extension] = result.firstPage; - if (isInstalled) { - return TPromise.wrapError(localize('alreadyInstalled', "Extension '{0}' is already installed.", id)); + if (!extension) { + return TPromise.wrapError(`${ notFound(id) }\n${ useId }`); } console.log(localize('foundExtension', "Found '{0}' in the marketplace.", id)); @@ -81,8 +82,8 @@ class Main { console.log(localize('successInstall', "Extension '{0}' v{1} was successfully installed!", id, extension.version)); }); }); - }); - })); + })); + }); } private uninstallExtension(ids: string[]): TPromise { -- GitLab