Skip to content

Commit 4de2ef7

Browse files
committed
FIX: Extract zip win
Related to #819 Changes consist in reordering extract utils to first attemps ExtractToDirectory and then Expand-Archive. For some reason the download CPython release was not correctly handled by Expand-Archive. This could be happening if the zip file was compressed using an unsupported compression method (e.g. through `zip` with Unix/linux).
1 parent 871daa9 commit 4de2ef7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

dist/setup/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9877,11 +9877,12 @@ function extractZipWin(file, dest) {
98779877
yield exec_1.exec(`"${pwshPath}"`, args);
98789878
}
98799879
else {
9880+
//attempt to use pwsh with ExtractToDirectory, if this fails attempt Expand-Archive
98809881
const powershellCommand = [
98819882
`$ErrorActionPreference = 'Stop' ;`,
98829883
`try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ;`,
9883-
`if ((Get-Command -Name Expand-Archive -Module Microsoft.PowerShell.Archive -ErrorAction Ignore)) { Expand-Archive -LiteralPath '${escapedFile}' -DestinationPath '${escapedDest}' -Force }`,
9884-
`else {[System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}', $true) }`
9884+
`try { [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}', $true) }`,
9885+
`catch { if (($_.Exception.GetType().FullName -eq 'System.Management.Automation.MethodException') -or ($_.Exception.GetType().FullName -eq 'System.Management.Automation.RuntimeException') ){ Expand-Archive -LiteralPath '${escapedFile}' -DestinationPath '${escapedDest}' -Force } else { throw $_ } } ;`
98859886
].join(' ');
98869887
const args = [
98879888
'-NoLogo',

0 commit comments

Comments
 (0)