@@ -9853,50 +9853,25 @@ function extractZipWin(file, dest) {
98539853 // build the powershell command
98549854 const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
98559855 const escapedDest = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
9856- const pwshPath = yield io.which('pwsh', false);
9857- //To match the file overwrite behavior on nix systems, we use the overwrite = true flag for ExtractToDirectory
9858- //and the -Force flag for Expand-Archive as a fallback
9859- if (pwshPath) {
9860- //attempt to use pwsh with ExtractToDirectory, if this fails attempt Expand-Archive
9861- const pwshCommand = [
9862- `$ErrorActionPreference = 'Stop' ;`,
9863- `try { Add-Type -AssemblyName System.IO.Compression.ZipFile } catch { } ;`,
9864- `try { [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}', $true) }`,
9865- `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 $_ } } ;`
9866- ].join(' ');
9867- const args = [
9868- '-NoLogo',
9869- '-NoProfile',
9870- '-NonInteractive',
9871- '-ExecutionPolicy',
9872- 'Unrestricted',
9873- '-Command',
9874- pwshCommand
9875- ];
9876- core.debug(`Using pwsh at path: ${pwshPath}`);
9877- yield exec_1.exec(`"${pwshPath}"`, args);
9878- }
9879- else {
9880- const powershellCommand = [
9881- `$ErrorActionPreference = 'Stop' ;`,
9882- `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) }`
9885- ].join(' ');
9886- const args = [
9887- '-NoLogo',
9888- '-Sta',
9889- '-NoProfile',
9890- '-NonInteractive',
9891- '-ExecutionPolicy',
9892- 'Unrestricted',
9893- '-Command',
9894- powershellCommand
9895- ];
9896- const powershellPath = yield io.which('powershell', true);
9897- core.debug(`Using powershell at path: ${powershellPath}`);
9898- yield exec_1.exec(`"${powershellPath}"`, args);
9899- }
9856+ const powershellCommand = [
9857+ `$ErrorActionPreference = 'Stop' ;`,
9858+ `try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ;`,
9859+ `if ((Get-Command -Name Expand-Archive -Module Microsoft.PowerShell.Archive -ErrorAction Ignore)) { Expand-Archive -LiteralPath '${escapedFile}' -DestinationPath '${escapedDest}' -Force }`,
9860+ `else {[System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}', $true) }`
9861+ ].join(' ');
9862+ const args = [
9863+ '-NoLogo',
9864+ '-Sta',
9865+ '-NoProfile',
9866+ '-NonInteractive',
9867+ '-ExecutionPolicy',
9868+ 'Unrestricted',
9869+ '-Command',
9870+ powershellCommand
9871+ ];
9872+ const powershellPath = yield io.which('powershell', true);
9873+ core.debug(`Using powershell at path: ${powershellPath}`);
9874+ yield exec_1.exec(`"${powershellPath}"`, args);
99009875 });
99019876}
99029877function extractZipNix(file, dest) {
0 commit comments