Skip to content

Commit e594385

Browse files
committed
Invoke Install Module
1 parent c2bba24 commit e594385

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

src/features/PowerShellFindModule.ts

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import Window = vscode.window;
44
import QuickPickItem = vscode.QuickPickItem;
55

66
export namespace FindModuleRequest {
7-
export const type: RequestType<any, any, void> = { get method() { return 'powerShell/findModule'; } };
7+
export const type: RequestType<any, any, void> = { get method() { return 'powerShell/findModule'; } };
8+
}
9+
10+
export namespace InstallModuleRequest {
11+
export const type: RequestType<string, void, void> = { get method() { return 'powerShell/InstallModule'; } };
812
}
913

1014
function GetCurrentTime() {
@@ -27,21 +31,24 @@ export function registerPowerShellFindModuleCommand(client: LanguageClient): voi
2731
var items: QuickPickItem[] = [];
2832

2933
vscode.window.setStatusBarMessage(GetCurrentTime() + " Querying PowerShell Gallery");
30-
31-
client.sendRequest(FindModuleRequest.type, null).then((modules) => {
32-
for(var i=0 ; i < modules.moduleList.length; i++) {
33-
var module = modules.moduleList[i];
34-
items.push({ label: module.name, description: module.description });
35-
}
34+
client.sendRequest(FindModuleRequest.type, null).then((modules) => {
35+
for(var i=0 ; i < modules.moduleList.length; i++) {
36+
var module = modules.moduleList[i];
37+
items.push({ label: module.name, description: module.description });
38+
}
3639

3740
vscode.window.setStatusBarMessage("");
38-
Window.showQuickPick(items).then((selection) => {
39-
switch (selection.label) {
40-
default :
41-
var message = "Installing PowerShell Module " + selection.label;
42-
vscode.window.setStatusBarMessage(message, 1500);
43-
}
44-
});
45-
});
41+
Window.showQuickPick(items).then((selection) => {
42+
if (!selection) { return; }
43+
switch (selection.label) {
44+
default :
45+
var moduleName = selection.label;
46+
47+
vscode.window.setStatusBarMessage("Installing PowerShell Module " + moduleName, 1500);
48+
49+
client.sendRequest(InstallModuleRequest.type, moduleName);
50+
}
51+
});
52+
});
4653
});
4754
}

0 commit comments

Comments
 (0)