-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chocolatey-visualstudio.extension: extract Get-VSChannelManifestItem …
- Loading branch information
1 parent
a26823a
commit d0b1e41
Showing
2 changed files
with
71 additions
and
40 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
chocolatey-visualstudio.extension/extensions/Get-VSChannelManifestItem.ps1
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,53 @@ | ||
function Get-VSChannelManifestItem | ||
{ | ||
[CmdletBinding()] | ||
Param | ||
( | ||
[Parameter(Mandatory = $true)] [System.Collections.IDictionary] $Manifest, | ||
[ValidateSet('Bootstrapper', 'Manifest')] [Parameter(Mandatory = $true)] [string] $ChannelItemType | ||
) | ||
|
||
$result = $null | ||
if ($Manifest -is [Collections.IDictionary] -and $Manifest.ContainsKey('channelItems')) | ||
{ | ||
$channelItems = $Manifest['channelItems'] | ||
if ($channelItems -is [array]) | ||
{ | ||
$channelItem = $channelItems | Where-Object { $_ -is [Collections.IDictionary] -and $_.ContainsKey('type') -and $_['type'] -eq $ChannelItemType } | ||
if (($channelItem | Measure-Object).Count -eq 1) | ||
{ | ||
if ($channelItem -is [Collections.IDictionary]) | ||
{ | ||
$result = $channelItem | ||
} | ||
else | ||
{ | ||
Write-Debug 'Manifest parsing error: channelItem is not IDictionary' | ||
} | ||
} | ||
else | ||
{ | ||
Write-Debug 'Manifest parsing error: zero or more than one channelItem objects found' | ||
} | ||
} | ||
else | ||
{ | ||
Write-Debug 'Manifest parsing error: channelItems is not an array' | ||
} | ||
} | ||
else | ||
{ | ||
Write-Debug 'Manifest parsing error: manifest is not IDictionary or does not contain channelItems' | ||
} | ||
|
||
if ($result -ne $null) | ||
{ | ||
Write-Debug "Located channel manifest item of type $ChannelItemType" | ||
} | ||
else | ||
{ | ||
Write-Debug "Could not locate the channel manifest item of type $ChannelItemType" | ||
} | ||
|
||
return $result | ||
} |
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