Skip to content

Commit

Permalink
Fix #73309
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed May 24, 2019
1 parent 3d50031 commit fa30470
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import { ExtensionsAutoProfiler } from 'vs/workbench/contrib/extensions/electron
import { onUnexpectedError } from 'vs/base/common/errors';
import { ExtensionDependencyChecker } from 'vs/workbench/contrib/extensions/electron-browser/extensionsDependencyChecker';
import { CancellationToken } from 'vs/base/common/cancellation';
import { ExtensionType } from 'vs/platform/extensions/common/extensions';

// Singletons
registerSingleton(IExtensionsWorkbenchService, ExtensionsWorkbenchService);
Expand Down Expand Up @@ -407,4 +408,35 @@ CommandsRegistry.registerCommand({
onUnexpectedError(e);
}
}
});

CommandsRegistry.registerCommand({
id: 'workbench.extensions.uninstallExtension',
description: {
description: localize('workbench.extensions.uninstallExtension.description', "Uninstall the given extension"),
args: [
{
name: localize('workbench.extensions.uninstallExtension.arg.name', "Id of the extension to uninstall"),
schema: {
'type': 'string'
}
}
]
},
handler: async (accessor, id: string) => {
if (!id) {
throw new Error(localize('id required', "Extension id required."));
}
const extensionManagementService = accessor.get(IExtensionManagementService);
try {
const installed = await extensionManagementService.getInstalled(ExtensionType.User);
const [extensionToUninstall] = installed.filter(e => areSameExtensions(e.identifier, { id }));
if (!extensionToUninstall) {
return Promise.reject(new Error(localize('notInstalled', "Extension '{0}' is not installed. Make sure you use the full extension ID, including the publisher, eg: ms-vscode.csharp.", id)));
}
await extensionManagementService.uninstall(extensionToUninstall, true);
} catch (e) {
onUnexpectedError(e);
}
}
});

0 comments on commit fa30470

Please sign in to comment.