Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/electron-browser/actions/installActions.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { localize, localize2 } from '../../../nls.js';
7
import { Action2 } from '../../../platform/actions/common/actions.js';
8
import { ILocalizedString } from '../../../platform/action/common/action.js';
9
import product from '../../../platform/product/common/product.js';
10
import { IDialogService } from '../../../platform/dialogs/common/dialogs.js';
11
import { ServicesAccessor } from '../../../platform/instantiation/common/instantiation.js';
12
import { INativeHostService } from '../../../platform/native/common/native.js';
13
import { toErrorMessage } from '../../../base/common/errorMessage.js';
14
import { IProductService } from '../../../platform/product/common/productService.js';
15
import { isCancellationError } from '../../../base/common/errors.js';
16
17
const shellCommandCategory: ILocalizedString = localize2('shellCommand', 'Shell Command');
18
19
export class InstallShellScriptAction extends Action2 {
20
21
constructor() {
22
super({
23
id: 'workbench.action.installCommandLine',
24
title: localize2('install', "Install '{0}' command in PATH", product.applicationName),
25
category: shellCommandCategory,
26
f1: true
27
});
28
}
29
30
async run(accessor: ServicesAccessor): Promise<void> {
31
const nativeHostService = accessor.get(INativeHostService);
32
const dialogService = accessor.get(IDialogService);
33
const productService = accessor.get(IProductService);
34
35
try {
36
await nativeHostService.installShellCommand();
37
38
dialogService.info(localize('successIn', "Shell command '{0}' successfully installed in PATH.", productService.applicationName));
39
} catch (error) {
40
if (isCancellationError(error)) {
41
return;
42
}
43
44
dialogService.error(toErrorMessage(error));
45
}
46
}
47
}
48
49
export class UninstallShellScriptAction extends Action2 {
50
51
constructor() {
52
super({
53
id: 'workbench.action.uninstallCommandLine',
54
title: localize2('uninstall', "Uninstall '{0}' command from PATH", product.applicationName),
55
category: shellCommandCategory,
56
f1: true
57
});
58
}
59
60
async run(accessor: ServicesAccessor): Promise<void> {
61
const nativeHostService = accessor.get(INativeHostService);
62
const dialogService = accessor.get(IDialogService);
63
const productService = accessor.get(IProductService);
64
65
try {
66
await nativeHostService.uninstallShellCommand();
67
68
dialogService.info(localize('successFrom', "Shell command '{0}' successfully uninstalled from PATH.", productService.applicationName));
69
} catch (error) {
70
if (isCancellationError(error)) {
71
return;
72
}
73
74
dialogService.error(toErrorMessage(error));
75
}
76
}
77
}
78
79