forked from RamblingCookieMonster/PSDepend
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal function to cater for legacy and new ps versions
- Loading branch information
Showing
3 changed files
with
31 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
function Expand-PSDependArchive { | ||
[CmdletBinding()] | ||
param ( | ||
[String] | ||
$Path, | ||
|
||
[String] | ||
$DestinationPath, | ||
|
||
[Switch] | ||
$Force | ||
) | ||
|
||
end { | ||
# Use Windows unzip method as otherwise Expand-Archive exists and that runs on all platforms | ||
if ($null -eq $(Get-Command -Name Expand-Archive -ErrorAction SilentlyContinue)) { | ||
Write-Verbose "Extracting using legacy unzip method" | ||
$ZipFile = (New-Object -com shell.application).NameSpace($Path) | ||
$ZipDestination = (New-Object -com shell.application).NameSpace($DestinationPath) | ||
$ZipDestination.CopyHere($ZipFile.Items()) | ||
} | ||
else { | ||
Write-Verbose "Extracting using current Expand-Archive function" | ||
Expand-Archive -Path $Path -DestinationPath $DestinationPath -Force:$Force | ||
} | ||
} | ||
} |