aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2018-02-28 18:43:41 -0800
committerAlexander Karatarakis <alkarata@microsoft.com>2018-02-28 18:45:33 -0800
commit6e0b74c7846216f1483949270df899415908cdf0 (patch)
treed2e3cd77eee68fd0c364db3336429ca3a8c541bd /scripts
parentd979d9b491192764729e82c619d28baaf2d21031 (diff)
downloadvcpkg-6e0b74c7846216f1483949270df899415908cdf0.tar.gz
vcpkg-6e0b74c7846216f1483949270df899415908cdf0.zip
[vcpkgHasProperty] Return false if property doesn't exist
Diffstat (limited to 'scripts')
-rw-r--r--scripts/VcpkgPowershellUtils.ps17
1 files changed, 6 insertions, 1 deletions
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"})
}