diff --git a/src/vs/code/node/cliProcessMain.ts b/src/vs/code/node/cliProcessMain.ts index 2aab9956ea29a3a46e02857a347fb6d1b1ad80d8..a6343b7414c94bca64eee0e716d674103ed96446 100644 --- a/src/vs/code/node/cliProcessMain.ts +++ b/src/vs/code/node/cliProcessMain.ts @@ -18,7 +18,7 @@ import { InstantiationService } from 'vs/platform/instantiation/common/instantia import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment'; import { EnvironmentService } from 'vs/platform/environment/node/environmentService'; import { IExtensionManagementService, IExtensionGalleryService, IExtensionManifest, IGalleryExtension, LocalExtensionType } from 'vs/platform/extensionManagement/common/extensionManagement'; -import { ExtensionManagementService } from 'vs/platform/extensionManagement/node/extensionManagementService'; +import { ExtensionManagementService, validateLocalExtension } from 'vs/platform/extensionManagement/node/extensionManagementService'; import { ExtensionGalleryService } from 'vs/platform/extensionManagement/node/extensionGalleryService'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { combinedAppender, NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils'; @@ -131,19 +131,30 @@ class Main { return sequence([...vsixTasks, ...galleryTasks]); } - private uninstallExtension(ids: string[]): TPromise { - return sequence(ids.map(id => () => { - return this.extensionManagementService.getInstalled(LocalExtensionType.User).then(installed => { - const [extension] = installed.filter(e => getId(e.manifest) === id); + private uninstallExtension(extensions: string[]): TPromise { + function extension2id(extension): TPromise { + if ( !/\.vsix$/i.test ( extension ) ) { + return TPromise.as ( extension ); + } else { + const zipPath = path.isAbsolute(extension) ? extension : path.join(process.cwd(), extension); + return validateLocalExtension(zipPath).then(getId); + } + } - if (!extension) { - return TPromise.wrapError(new Error(`${notInstalled(id)}\n${useId}`)); - } + return sequence(extensions.map(extension => () => { + return extension2id(extension).then(id => { + return this.extensionManagementService.getInstalled(LocalExtensionType.User).then(installed => { + const [extension] = installed.filter(e => getId(e.manifest) === id); + + if (!extension) { + return TPromise.wrapError(new Error(`${notInstalled(id)}\n${useId}`)); + } - console.log(localize('uninstalling', "Uninstalling {0}...", id)); + console.log(localize('uninstalling', "Uninstalling {0}...", id)); - return this.extensionManagementService.uninstall(extension, true) - .then(() => console.log(localize('successUninstall', "Extension '{0}' was successfully uninstalled!", id))); + return this.extensionManagementService.uninstall(extension, true) + .then(() => console.log(localize('successUninstall', "Extension '{0}' was successfully uninstalled!", id))); + }); }); })); } diff --git a/src/vs/platform/environment/node/argv.ts b/src/vs/platform/environment/node/argv.ts index 7f81ffa9d2f12fb394bb9e2768a97f5e78be19f0..a04b43f306cf95e40043ad90031e321187172dff 100644 --- a/src/vs/platform/environment/node/argv.ts +++ b/src/vs/platform/environment/node/argv.ts @@ -134,7 +134,7 @@ export const optionsHelp: { [name: string]: string; } = { '--list-extensions': localize('listExtensions', "List the installed extensions."), '--show-versions': localize('showVersions', "Show versions of installed extensions, when using --list-extension."), '--install-extension ( | )': localize('installExtension', "Installs an extension."), - '--uninstall-extension ': localize('uninstallExtension', "Uninstalls an extension."), + '--uninstall-extension ( | )': localize('uninstallExtension', "Uninstalls an extension."), '--enable-proposed-api ': localize('experimentalApis', "Enables proposed api features for an extension."), '--disable-extensions': localize('disableExtensions', "Disable all installed extensions."), '--disable-gpu': localize('disableGPU', "Disable GPU hardware acceleration."), diff --git a/src/vs/platform/extensionManagement/node/extensionManagementService.ts b/src/vs/platform/extensionManagement/node/extensionManagementService.ts index e019353ebcec5f82897d5a19c483b6b431593ed3..2a1dcf95a9c2a3b03677b4c97af1d81fbca57802 100644 --- a/src/vs/platform/extensionManagement/node/extensionManagementService.ts +++ b/src/vs/platform/extensionManagement/node/extensionManagementService.ts @@ -45,7 +45,7 @@ function parseManifest(raw: string): TPromise<{ manifest: IExtensionManifest; me }); } -function validate(zipPath: string): TPromise { +export function validateLocalExtension(zipPath: string): TPromise { return buffer(zipPath, 'extension/package.json') .then(buffer => parseManifest(buffer.toString('utf8'))) .then(({ manifest }) => TPromise.as(manifest)); @@ -102,7 +102,7 @@ export class ExtensionManagementService implements IExtensionManagementService { install(zipPath: string): TPromise { zipPath = path.resolve(zipPath); - return validate(zipPath).then(manifest => { + return validateLocalExtension(zipPath).then(manifest => { const id = getLocalExtensionIdFromManifest(manifest); return this.isObsolete(id).then(isObsolete => { @@ -262,7 +262,7 @@ export class ExtensionManagementService implements IExtensionManagementService { }; return this.galleryService.download(extension) - .then(zipPath => validate(zipPath).then(() => zipPath)) + .then(zipPath => validateLocalExtension(zipPath).then(() => zipPath)) .then(zipPath => this.installExtension(zipPath, id, metadata)); }