From 35fad4d2bc022b7053b5390ec1fb47ca28f4086e Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 27 Sep 2023 17:57:58 -0400 Subject: [PATCH] fix(upgrade): use tar.exe to extract on Windows (#20711) This is what we do for deno install, so it should be fine here https://github.com/denoland/deno_install/pull/219 Closes https://github.com/denoland/deno/issues/20683 --- cli/tools/upgrade.rs | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/cli/tools/upgrade.rs b/cli/tools/upgrade.rs index 366cc7fc45cd9c..04332f5dfc675f 100644 --- a/cli/tools/upgrade.rs +++ b/cli/tools/upgrade.rs @@ -481,7 +481,7 @@ async fn download_package( match maybe_bytes { Some(bytes) => Ok(bytes), None => { - log::info!("Download could not be found, aborting"); + log::error!("Download could not be found, aborting"); std::process::exit(1) } } @@ -506,32 +506,17 @@ pub fn unpack_into_dir( let unpack_status = match archive_ext { "zip" if cfg!(windows) => { fs::write(&archive_path, &archive_data)?; - Command::new("powershell.exe") - .arg("-NoLogo") - .arg("-NoProfile") - .arg("-NonInteractive") - .arg("-Command") - .arg( - "& { - param($Path, $DestinationPath) - trap { $host.ui.WriteErrorLine($_.Exception); exit 1 } - Add-Type -AssemblyName System.IO.Compression.FileSystem - [System.IO.Compression.ZipFile]::ExtractToDirectory( - $Path, - $DestinationPath - ); - }", - ) - .arg("-Path") - .arg(format!("'{}'", &archive_path.to_str().unwrap())) - .arg("-DestinationPath") - .arg(format!("'{}'", &temp_dir_path.to_str().unwrap())) + Command::new("tar.exe") + .arg("xf") + .arg(&archive_path) + .arg("-C") + .arg(temp_dir_path) .spawn() .map_err(|err| { if err.kind() == std::io::ErrorKind::NotFound { std::io::Error::new( std::io::ErrorKind::NotFound, - "`powershell.exe` was not found in your PATH", + "`tar.exe` was not found in your PATH", ) } else { err