Skip to content

Commit

Permalink
fix(autoupdate): Update array of arrays correctly (#4502)
Browse files Browse the repository at this point in the history
  • Loading branch information
niheaven authored Nov 8, 2021
1 parent dcce404 commit 1490869
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions lib/autoupdate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -346,15 +346,25 @@ function Update-ManifestProperty {
}
} elseif ($Manifest.$currentProperty -and $Manifest.autoupdate.$currentProperty) {
# Update other property (global)
$newValue = substitute $Manifest.autoupdate.$currentProperty $Substitutions
$autoupdateProperty = $Manifest.autoupdate.$currentProperty
$newValue = substitute $autoupdateProperty $Substitutions
if (($autoupdateProperty.GetType().Name -eq 'Object[]') -and ($autoupdateProperty.Length -eq 1)) {
# Make sure it's an array
$newValue = ,$newValue
}
$Manifest.$currentProperty, $hasPropertyChanged = PropertyHelper -Property $Manifest.$currentProperty -Value $newValue
$hasManifestChanged = $hasManifestChanged -or $hasPropertyChanged
} elseif ($Manifest.architecture) {
# Update other property (arch-spec)
$Manifest.architecture | Get-Member -MemberType NoteProperty | ForEach-Object {
$arch = $_.Name
if ($Manifest.architecture.$arch.$currentProperty -and ($Manifest.autoupdate.architecture.$arch.$currentProperty -or $Manifest.autoupdate.$currentProperty)) {
$newValue = substitute (arch_specific $currentProperty $Manifest.autoupdate $arch) $Substitutions
$autoupdateProperty = @(arch_specific $currentProperty $Manifest.autoupdate $arch)
$newValue = substitute $autoupdateProperty $Substitutions
if (($autoupdateProperty.GetType().Name -eq 'Object[]') -and ($autoupdateProperty.Length -eq 1)) {
# Make sure it's an array
$newValue = ,$newValue
}
$Manifest.architecture.$arch.$currentProperty, $hasPropertyChanged = PropertyHelper -Property $Manifest.architecture.$arch.$currentProperty -Value $newValue
$hasManifestChanged = $hasManifestChanged -or $hasPropertyChanged
}
Expand Down
2 changes: 1 addition & 1 deletion lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ function substitute($entity, [Hashtable] $params, [Bool]$regexEscape = $false) {
}
}
'Object[]' {
$newentity = $entity | ForEach-Object { substitute $_ $params $regexEscape }
$newentity = $entity | ForEach-Object { ,(substitute $_ $params $regexEscape) }
}
'PSCustomObject' {
$newentity.PSObject.Properties | ForEach-Object { $_.Value = substitute $_.Value $params $regexEscape }
Expand Down

0 comments on commit 1490869

Please sign in to comment.