Skip to content

Commit 1490869

Browse files
authored
fix(autoupdate): Update array of arrays correctly (#4502)
1 parent dcce404 commit 1490869

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

lib/autoupdate.ps1

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,15 +346,25 @@ function Update-ManifestProperty {
346346
}
347347
} elseif ($Manifest.$currentProperty -and $Manifest.autoupdate.$currentProperty) {
348348
# Update other property (global)
349-
$newValue = substitute $Manifest.autoupdate.$currentProperty $Substitutions
349+
$autoupdateProperty = $Manifest.autoupdate.$currentProperty
350+
$newValue = substitute $autoupdateProperty $Substitutions
351+
if (($autoupdateProperty.GetType().Name -eq 'Object[]') -and ($autoupdateProperty.Length -eq 1)) {
352+
# Make sure it's an array
353+
$newValue = ,$newValue
354+
}
350355
$Manifest.$currentProperty, $hasPropertyChanged = PropertyHelper -Property $Manifest.$currentProperty -Value $newValue
351356
$hasManifestChanged = $hasManifestChanged -or $hasPropertyChanged
352357
} elseif ($Manifest.architecture) {
353358
# Update other property (arch-spec)
354359
$Manifest.architecture | Get-Member -MemberType NoteProperty | ForEach-Object {
355360
$arch = $_.Name
356361
if ($Manifest.architecture.$arch.$currentProperty -and ($Manifest.autoupdate.architecture.$arch.$currentProperty -or $Manifest.autoupdate.$currentProperty)) {
357-
$newValue = substitute (arch_specific $currentProperty $Manifest.autoupdate $arch) $Substitutions
362+
$autoupdateProperty = @(arch_specific $currentProperty $Manifest.autoupdate $arch)
363+
$newValue = substitute $autoupdateProperty $Substitutions
364+
if (($autoupdateProperty.GetType().Name -eq 'Object[]') -and ($autoupdateProperty.Length -eq 1)) {
365+
# Make sure it's an array
366+
$newValue = ,$newValue
367+
}
358368
$Manifest.architecture.$arch.$currentProperty, $hasPropertyChanged = PropertyHelper -Property $Manifest.architecture.$arch.$currentProperty -Value $newValue
359369
$hasManifestChanged = $hasManifestChanged -or $hasPropertyChanged
360370
}

lib/core.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ function substitute($entity, [Hashtable] $params, [Bool]$regexEscape = $false) {
864864
}
865865
}
866866
'Object[]' {
867-
$newentity = $entity | ForEach-Object { substitute $_ $params $regexEscape }
867+
$newentity = $entity | ForEach-Object { ,(substitute $_ $params $regexEscape) }
868868
}
869869
'PSCustomObject' {
870870
$newentity.PSObject.Properties | ForEach-Object { $_.Value = substitute $_.Value $params $regexEscape }

0 commit comments

Comments
 (0)