Skip to content

Commit 5483758

Browse files
Close other pwsh's in the VSCode instance (#2469)
1 parent 92c1c75 commit 5483758

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"windows": {
55
"options": {
66
"shell": {
7-
"executable": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
7+
"executable": "pwsh.exe",
88
"args": [ "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command" ]
99
}
1010
}

src/features/UpdatePowerShell.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ export async function InvokePowerShellUpdateCheck(
116116

117117
const result = await window.showInformationMessage(
118118
`${commonText} Would you like to update the version? ${
119-
isMacOS ? "(Homebrew is required on macOS)" : ""
119+
isMacOS ? "(Homebrew is required on macOS)"
120+
: "(This will close ALL pwsh terminals running in this Visual Studio Code session)"
120121
}`, ...options);
121122

122123
// If the user cancels the notification.
@@ -151,6 +152,15 @@ export async function InvokePowerShellUpdateCheck(
151152
// Stop the Integrated Console session because Windows likes to hold on to files.
152153
sessionManager.stop();
153154

155+
// Close all terminals with the name "pwsh" in the current VS Code session.
156+
// This will encourage folks to not close the instance of VS Code that spawned
157+
// the MSI process.
158+
for (const terminal of window.terminals) {
159+
if (terminal.name === "pwsh") {
160+
terminal.dispose();
161+
}
162+
}
163+
154164
// Invoke the MSI via cmd.
155165
const msi = spawn("msiexec", ["/i", msiDownloadPath]);
156166

0 commit comments

Comments
 (0)