fix: 'deno upgrade' doesn't work on Windows 8.1/PowerShell 4.0
Fixes:
@@ -172,20 +172,33 @@ fn unpack(archive_data: Vec<u8>) -> Result<PathBuf, ErrBox> {
cmd.stdin.as_mut().unwrap().write_all(&archive_data)?;
cmd.wait()?
}
- "zip" => {
- if cfg!(windows) {
+ "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("Expand-Archive")
+ .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()?
- } else {
+ }
+ "zip" => {
let archive_path = temp_dir.join("deno.zip");
fs::write(&archive_path, &archive_data)?;
Command::new("unzip")
@@ -194,7 +207,6 @@ fn unpack(archive_data: Vec<u8>) -> Result<PathBuf, ErrBox> {
.spawn()?
.wait()?
}
- }
ext => panic!("Unsupported archive type: '{}'", ext),
};
assert!(unpack_status.success());
