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:
parent
ee7727cd07
commit
18670c47e6
1 changed files with 33 additions and 21 deletions
|
@ -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),
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue