diff options
author | Bert Belder <bertbelder@gmail.com> | 2020-06-05 21:46:03 +0200 |
---|---|---|
committer | Bert Belder <bertbelder@gmail.com> | 2020-06-05 22:16:44 +0200 |
commit | 18670c47e69ec2b9ceef6ec0011fbbdc4b845be6 (patch) | |
tree | d136eec4ea4fb5024835d5edbf102e655efb8110 | |
parent | ee7727cd078b56d2ecc5d93f9308709e60a18949 (diff) |
fix: 'deno upgrade' doesn't work on Windows 8.1/PowerShell 4.0 (#6132)
Fixes: #6109
-rw-r--r-- | cli/upgrade.rs | 54 |
1 files changed, 33 insertions, 21 deletions
diff --git a/cli/upgrade.rs b/cli/upgrade.rs index b4f207643..dcf166a71 100644 --- a/cli/upgrade.rs +++ b/cli/upgrade.rs @@ -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), }; |