summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/tools/upgrade.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/cli/tools/upgrade.rs b/cli/tools/upgrade.rs
index b1b09d1a6..77a9f72b8 100644
--- a/cli/tools/upgrade.rs
+++ b/cli/tools/upgrade.rs
@@ -579,6 +579,10 @@ pub async fn upgrade(
let output_exe_path =
full_path_output_flag.as_ref().unwrap_or(&current_exe_path);
+
+ #[cfg(windows)]
+ kill_running_deno_lsp_processes();
+
let output_result = if *output_exe_path == current_exe_path {
replace_exe(&new_exe_path, output_exe_path)
} else {
@@ -966,6 +970,34 @@ fn check_windows_access_denied_error(
})
}
+#[cfg(windows)]
+fn kill_running_deno_lsp_processes() {
+ // limit this to `deno lsp` invocations to avoid killing important programs someone might be running
+ let is_debug = log::log_enabled!(log::Level::Debug);
+ let get_pipe = || {
+ if is_debug {
+ std::process::Stdio::inherit()
+ } else {
+ std::process::Stdio::null()
+ }
+ };
+ let _ = Command::new("powershell.exe")
+ .args([
+ "-Command",
+ r#"Get-WmiObject Win32_Process | Where-Object {
+ $_.Name -eq 'deno.exe' -and
+ $_.CommandLine -match '^(?:\"[^\"]+\"|\S+)\s+lsp\b'
+} | ForEach-Object {
+ if ($_.Terminate()) {
+ Write-Host 'Terminated:' $_.ProcessId
+ }
+}"#,
+ ])
+ .stdout(get_pipe())
+ .stderr(get_pipe())
+ .output();
+}
+
fn set_exe_permissions(
current_exe_path: &Path,
output_exe_path: &Path,