Skip to content

Commit c46c2cf

Browse files
committed
Improve type and null handling
1 parent 52e3eda commit c46c2cf

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

eng/common/scripts/job-matrix/job-matrix-functions.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ function ProcessReplace {
338338
$replaceMatrix = @()
339339

340340
foreach ($element in $matrix) {
341-
if (!$element || [bool]$element.PSobject.Properties.name -notmatch "_permutation") {
341+
if (!$element || $element.PSobject.Properties.name -notcontains "_permutation") {
342342
continue
343343
}
344344
$replacement = [MatrixParameter[]]@()
@@ -374,15 +374,15 @@ function ProcessEnvironmentVariableReferences([array]$matrix, $displayNamesLooku
374374
$updatedMatrix = @()
375375

376376
foreach ($element in $matrix) {
377-
if (!$element || [bool]$element.PSobject.Properties.name -notmatch "_permutation") {
377+
if (!$element || $element.PSobject.Properties.name -notcontains "_permutation") {
378378
continue
379379
}
380380
$updated = [MatrixParameter[]]@()
381381

382382
foreach ($perm in $element._permutation) {
383383
# Iterate nested permutations or run once for singular values (int, string, bool)
384384
foreach ($flattened in $perm.Flatten()) {
385-
if ($flattened.Value?.GetType() -eq "".GetType() -and $flattened.Value.StartsWith("env:")) {
385+
if ($flattened.Value -is [string] -and $flattened.Value.StartsWith("env:")) {
386386
$envKey = $flattened.Value.Replace("env:", "")
387387
$value = [System.Environment]::GetEnvironmentVariable($envKey) ?? ""
388388
if (!$value) {

0 commit comments

Comments
 (0)