From 6e0b74c7846216f1483949270df899415908cdf0 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Wed, 28 Feb 2018 18:43:41 -0800 Subject: [vcpkgHasProperty] Return false if property doesn't exist --- scripts/VcpkgPowershellUtils.ps1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/VcpkgPowershellUtils.ps1 b/scripts/VcpkgPowershellUtils.ps1 index 088519c37..2dbf04085 100644 --- a/scripts/VcpkgPowershellUtils.ps1 +++ b/scripts/VcpkgPowershellUtils.ps1 @@ -3,8 +3,13 @@ function vcpkgHasModule([Parameter(Mandatory=$true)][string]$moduleName) return [bool](Get-Module -ListAvailable -Name $moduleName) } -function vcpkgHasProperty([Parameter(Mandatory=$true)]$object, [Parameter(Mandatory=$true)]$propertyName) +function vcpkgHasProperty([Parameter(Mandatory=$true)][AllowNull()]$object, [Parameter(Mandatory=$true)]$propertyName) { + if ($object -eq $null) + { + return $false + } + return [bool]($object.psobject.Properties | where { $_.Name -eq "$propertyName"}) } -- cgit v1.2.3