1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-05 13:59:01 -05:00

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
This commit is contained in:
David Sherret 2023-09-27 17:57:58 -04:00 committed by Bartek Iwańczuk
parent 3f7207d1a9
commit f5243f1dbd
No known key found for this signature in database
GPG key ID: 0C6BCDDC3B3AD750

View file

@ -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