Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close other pwsh's in the VSCode instance #2469

Merged
merged 1 commit into from
Feb 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"windows": {
"options": {
"shell": {
"executable": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"executable": "pwsh.exe",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

"args": [ "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command" ]
}
}
Expand Down
12 changes: 11 additions & 1 deletion src/features/UpdatePowerShell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ export async function InvokePowerShellUpdateCheck(

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

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

// Close all terminals with the name "pwsh" in the current VS Code session.
// This will encourage folks to not close the instance of VS Code that spawned
// the MSI process.
for (const terminal of window.terminals) {
if (terminal.name === "pwsh") {
terminal.dispose();
}
}

// Invoke the MSI via cmd.
const msi = spawn("msiexec", ["/i", msiDownloadPath]);

Expand Down