summaryrefslogtreecommitdiff
path: root/cli/tools/upgrade.rs
diff options
context:
space:
mode:
authorhaturau <135221985+haturatu@users.noreply.github.com>2024-11-20 01:20:47 +0900
committerGitHub <noreply@github.com>2024-11-20 01:20:47 +0900
commit85719a67e59c7aa45bead26e4942d7df8b1b42d4 (patch)
treeface0aecaac53e93ce2f23b53c48859bcf1a36ec /cli/tools/upgrade.rs
parent67697bc2e4a62a9670699fd18ad0dd8efc5bd955 (diff)
parent186b52731c6bb326c4d32905c5e732d082e83465 (diff)
Merge branch 'denoland:main' into main
Diffstat (limited to 'cli/tools/upgrade.rs')
-rw-r--r--cli/tools/upgrade.rs36
1 files changed, 34 insertions, 2 deletions
diff --git a/cli/tools/upgrade.rs b/cli/tools/upgrade.rs
index 7f21e6649..cb85859f7 100644
--- a/cli/tools/upgrade.rs
+++ b/cli/tools/upgrade.rs
@@ -540,7 +540,7 @@ pub async fn upgrade(
let Some(archive_data) = download_package(&client, download_url).await?
else {
log::error!("Download could not be found, aborting");
- std::process::exit(1)
+ deno_runtime::exit(1)
};
log::info!(
@@ -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 {
@@ -913,7 +917,7 @@ async fn download_package(
// text above which will stay alive after the progress bars are complete
let progress = progress_bar.update("");
let maybe_bytes = client
- .download_with_progress(download_url.clone(), None, &progress)
+ .download_with_progress_and_retries(download_url.clone(), None, &progress)
.await
.with_context(|| format!("Failed downloading {download_url}. The version you requested may not have been built for the current architecture."))?;
Ok(maybe_bytes)
@@ -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,