forked from chocolatey-community/chocolatey-diff
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(chocolatey-communityGH-30) Move code for extracting meta data to its…
… own function
- Loading branch information
1 parent
0655430
commit cebbf8b
Showing
3 changed files
with
51 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#Requires -Modules chocolatey-diff | ||
|
||
Describe "Get-PackageBinaryData tests" { | ||
} |
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,44 @@ | ||
function Get-PackageBinaryData { | ||
<# | ||
.SYNOPSIS | ||
The meta information about binaries included in package | ||
.DESCRIPTION | ||
The meta information about binaries included in the package, including | ||
the relative path, the checksum of the file, the embedded file and product | ||
version as well as the embedded company name. | ||
.OUTPUTS | ||
An array of hashtables with the basic information about each binary file. | ||
.EXAMPLE | ||
PS > Get-PackageBinaryData -packageDirectory path\to\package\dir | ||
#> | ||
param ( | ||
[Parameter(Mandatory = $true)] | ||
[string]$packageDirectory, | ||
[ValidateSet('sha1', 'sha256', 'sha512')] | ||
[string]$hashAlgorithm = 'sha256' | ||
) | ||
|
||
Push-Location $packageDirectory | Out-Null | ||
|
||
try { | ||
Write-Verbose "Finding binary files in '$packageDirectory..." | ||
$binaryFiles = Get-ChildItem -Path $packageDirectory -Recurse -File | ? { Test-IsBinary -Path $_.FullName } | ||
|
||
foreach ($file in $binaryFiles) { | ||
Write-Verbose "Aquiring binary data from $($file.Name)..." | ||
|
||
$item = Get-Item $file.FullName | ||
$result = @{ | ||
path = Resolve-Path $file.FullName -Relative | ||
checksum = Get-FileHash $file.FullName -Algorithm $hashAlgorithm | % Hash | ||
fileVersion = $item.VersionInfo.FileVersion | ||
productVersion = $item.VersionInfo.ProductVersion | ||
CompanyName = $item.VersionInfo.CompanyName | ||
} | ||
$result | ||
} | ||
} finally { | ||
|
||
Pop-Location | Out-Null | ||
} | ||
} |
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