diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2018-02-28 18:43:41 -0800 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2018-02-28 18:45:33 -0800 |
| commit | 6e0b74c7846216f1483949270df899415908cdf0 (patch) | |
| tree | d2e3cd77eee68fd0c364db3336429ca3a8c541bd /scripts | |
| parent | d979d9b491192764729e82c619d28baaf2d21031 (diff) | |
| download | vcpkg-6e0b74c7846216f1483949270df899415908cdf0.tar.gz vcpkg-6e0b74c7846216f1483949270df899415908cdf0.zip | |
[vcpkgHasProperty] Return false if property doesn't exist
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/VcpkgPowershellUtils.ps1 | 7 |
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"}) } |
