Skip to content

Commit aa052a7

Browse files
committed
CI: enumerate ConvertFrom-Json arrays on Windows PowerShell 5.1
1 parent 84edc69 commit aa052a7

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎.github/actions/upgrade-ca-certificates/emudhra_intermediates.ps1‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ function Get-CertificateSha256([System.Security.Cryptography.X509Certificates.X5
2929
# Returns the certificates as X509Certificate2 objects; callers dispose them.
3030
# Works on both Windows PowerShell 5.1 and PowerShell 7+.
3131
function Get-EmudhraIntermediates {
32-
$entries = @(Get-Content -LiteralPath $EmudhraIntermediatesPath -Raw | ConvertFrom-Json)
32+
# Windows PowerShell 5.1's ConvertFrom-Json emits a JSON array as a single
33+
# object; piping it through ForEach-Object enumerates it on both versions.
34+
$parsed = Get-Content -LiteralPath $EmudhraIntermediatesPath -Raw | ConvertFrom-Json
35+
$entries = @($parsed | ForEach-Object { $_ })
3336
if ($entries.Count -ne $EmudhraIntermediatesCount) {
3437
throw "Expected $EmudhraIntermediatesCount certificates in $EmudhraIntermediatesPath, found $($entries.Count)."
3538
}

0 commit comments

Comments
 (0)