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

fix: 'deno upgrade' doesn't work on Windows 8.1/PowerShell 4.0 (#6132)

Fixes: #6109
This commit is contained in:
Bert Belder 2020-06-05 21:46:03 +02:00
parent ee7727cd07
commit 18670c47e6
No known key found for this signature in database
GPG key ID: 7A77887B2E2ED461

View file

@ -172,28 +172,40 @@ fn unpack(archive_data: Vec<u8>) -> Result<PathBuf, ErrBox> {
cmd.stdin.as_mut().unwrap().write_all(&archive_data)?;
cmd.wait()?
}
"zip" if cfg!(windows) => {
let archive_path = temp_dir.join("deno.zip");
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(&archive_path)
.arg("-DestinationPath")
.arg(&temp_dir)
.spawn()?
.wait()?
}
"zip" => {
if cfg!(windows) {
let archive_path = temp_dir.join("deno.zip");
fs::write(&archive_path, &archive_data)?;
Command::new("powershell.exe")
.arg("-Command")
.arg("Expand-Archive")
.arg("-Path")
.arg(&archive_path)
.arg("-DestinationPath")
.arg(&temp_dir)
.spawn()?
.wait()?
} else {
let archive_path = temp_dir.join("deno.zip");
fs::write(&archive_path, &archive_data)?;
Command::new("unzip")
.current_dir(&temp_dir)
.arg(archive_path)
.spawn()?
.wait()?
}
let archive_path = temp_dir.join("deno.zip");
fs::write(&archive_path, &archive_data)?;
Command::new("unzip")
.current_dir(&temp_dir)
.arg(archive_path)
.spawn()?
.wait()?
}
ext => panic!("Unsupported archive type: '{}'", ext),
};