ps/Modules/Alkami.PowerShell.Choco/Public/Test-IsPackageInFeed.ps1
2023-05-30 22:51:22 -07:00

36 lines
861 B
PowerShell

function Test-IsPackageInFeed {
<#
.SYNOPSIS
Returns true if a particular name/version of a package is in a given nuget/chocolatey source feed.
.PARAMETER Name
The package name
.PARAMETER Source
The package source url
.PARAMETER Version
The package version
#>
[CmdletBinding()]
[OutputType([System.Boolean])]
Param(
[Parameter(Mandatory = $false)]
[Alias("s")]
[string]$Source = "",
[Parameter(Mandatory = $false)]
[Alias("n")]
[string]$Name = "",
[Parameter(Mandatory = $false)]
[Alias("v")]
[string]$Version = ""
)
## TODO: Would this be faster as a proget lookup?
## TODO: Cleanup to match standards
## TODO: Use Get-ChocoState
$package = (choco search "$Name" --version "$Version" -r -s "$Source")
return ($null -ne $package)
}