File tree Expand file tree Collapse file tree 3 files changed +31
-14
lines changed Expand file tree Collapse file tree 3 files changed +31
-14
lines changed Original file line number Diff line number Diff line change @@ -456,18 +456,8 @@ if(($PSDependAction -contains 'Install') -and $ShouldInstall)
456456 return
457457 }
458458
459- # Extract the zip file
460- if (($script :IsWindows ) -and ($psEdition -eq ' Desktop' ) -and ($null -eq $ (Get-Command - Name Expand-Archive )))
461- {
462- $ZipFile = (New-Object - com shell.application).NameSpace($OutFile )
463- $ZipDestination = (New-Object - com shell.application).NameSpace($OutPath )
464- $ZipDestination.CopyHere ($ZipFile.Items ())
465- }
466- else
467- {
468- # If not on Windows "Expand-Archive" should be available as PS version 6 is considered minimum.
469- Expand-Archive $OutFile - DestinationPath $OutPath
470- }
459+ # Use our internal implementation to cater for Windows PS 5.1 and below + pwsh 6+
460+ Expand-PSDependArchive - Path $OutFile - DestinationPath $OutPath
471461
472462 # Remove the zip file
473463 Remove-Item $OutFile - Force - Confirm:$false
Original file line number Diff line number Diff line change @@ -135,8 +135,8 @@ if ($PSDependAction -eq "Install" -and $InstallNeeded) {
135135 Write-Verbose " Version of zip found at $DownloadPath "
136136 }
137137
138- $Out = Expand-Archive - Path $DownloadPath - DestinationPath $Path - Force - PassThru
139- Write-Verbose " Terraform installed to $Out "
138+ Expand-PSDependArchive - Path $DownloadPath - DestinationPath $Path - Force
139+ Write-Verbose " Terraform installed to $Path "
140140
141141 if ($Dependency.AddToPath ) {
142142 Write-Verbose " Setting PATH to`n $ ( $Path , $env: PATH -join ' ;' | Out-String ) "
Original file line number Diff line number Diff line change 1+ function Expand-PSDependArchive {
2+ [CmdletBinding ()]
3+ param (
4+ [String ]
5+ $Path ,
6+
7+ [String ]
8+ $DestinationPath ,
9+
10+ [Switch ]
11+ $Force
12+ )
13+
14+ end {
15+ # Use Windows unzip method as otherwise Expand-Archive exists and that runs on all platforms
16+ if ($null -eq $ (Get-Command - Name Expand-Archive - ErrorAction SilentlyContinue)) {
17+ Write-Verbose " Extracting using legacy unzip method"
18+ $ZipFile = (New-Object - com shell.application).NameSpace($Path )
19+ $ZipDestination = (New-Object - com shell.application).NameSpace($DestinationPath )
20+ $ZipDestination.CopyHere ($ZipFile.Items ())
21+ }
22+ else {
23+ Write-Verbose " Extracting using current Expand-Archive function"
24+ Expand-Archive - Path $Path - DestinationPath $DestinationPath - Force:$Force
25+ }
26+ }
27+ }
You can’t perform that action at this time.
0 commit comments