diff --git a/src/vs/code/node/cliProcessMain.ts b/src/vs/code/node/cliProcessMain.ts index d3fe06e80822060e8e1b8ea761bbbc5049a8cc78..07bd80a27bb0dc741b5ca6db559b31bf40445bdd 100644 --- a/src/vs/code/node/cliProcessMain.ts +++ b/src/vs/code/node/cliProcessMain.ts @@ -19,7 +19,7 @@ import { InstantiationService } from 'vs/platform/instantiation/common/instantia import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment'; import { EnvironmentService, getInstallSourcePath } 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'; @@ -142,19 +142,31 @@ 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 { + async function getExtensionId(extensionDescription: string): TPromise { + if (!/\.vsix$/i.test(extensionDescription)) { + return extensionDescription; + } - if (!extension) { - return TPromise.wrapError(new Error(`${notInstalled(id)}\n${useId}`)); - } + const zipPath = path.isAbsolute(extensionDescription) ? extensionDescription : path.join(process.cwd(), extensionDescription); + const manifest = await validateLocalExtension(zipPath); + return getId(manifest); + } + + return sequence(extensions.map(extension => () => { + return getExtensionId(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 8914588e0da6e7399b6e7a01de49ead188c7bf5d..648d5c3f95b37a7c6bf35d26d0219b5cedbd5960 100644 --- a/src/vs/platform/environment/node/argv.ts +++ b/src/vs/platform/environment/node/argv.ts @@ -139,7 +139,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 8d8d9215728205e98d5955f7cfa63f0c072b1c96..c655d1e74b71145e482f845d848c62a39f25d2ee 100644 --- a/src/vs/platform/extensionManagement/node/extensionManagementService.ts +++ b/src/vs/platform/extensionManagement/node/extensionManagementService.ts @@ -49,7 +49,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)); @@ -113,7 +113,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 identifier = { id: getLocalExtensionIdFromManifest(manifest) }; return this.isObsolete(identifier.id).then(isObsolete => { @@ -192,7 +192,7 @@ export class ExtensionManagementService implements IExtensionManagementService { publisherDisplayName: extension.publisherDisplayName, }; return this.galleryService.download(extension) - .then(zipPath => validate(zipPath).then(() => ({ zipPath, id, metadata, current }))); + .then(zipPath => validateLocalExtension(zipPath).then(() => ({ zipPath, id, metadata, current }))); } private rollback(extensions: IGalleryExtension[]): TPromise {