-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathpreuninstall.ts
29 lines (22 loc) · 1.01 KB
/
preuninstall.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import * as path from "path";
import { doesCurrentNpmCommandMatch } from "../helpers";
export class PreUninstallCommand implements ICommand {
public disableAnalytics = true;
public allowedParameters: ICommandParameter[] = [];
constructor(private $extensibilityService: IExtensibilityService,
private $fs: IFileSystem,
private $packageInstallationManager: IPackageInstallationManager,
private $settingsService: ISettingsService) { }
public async execute(args: string[]): Promise<void> {
const isIntentionalUninstall = doesCurrentNpmCommandMatch([/^uninstall$/, /^remove$/, /^rm$/, /^r$/, /^un$/, /^unlink$/]);
if (isIntentionalUninstall) {
this.handleIntentionalUninstall();
}
this.$fs.deleteFile(path.join(this.$settingsService.getProfileDir(), "KillSwitches", "cli"));
}
private handleIntentionalUninstall(): void {
this.$extensibilityService.removeAllExtensions();
this.$packageInstallationManager.clearInspectorCache();
}
}
$injector.registerCommand("dev-preuninstall", PreUninstallCommand);