Skip to content

Commit 76aaab8

Browse files
committed
PowerShell: Edge cases around flattened arrays
1 parent 1ef0c18 commit 76aaab8

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

eng/scripts/Pack-Crates.ps1

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,14 @@ function Get-PackagesToBuild() {
7777
$packages = Get-CargoPackages
7878
$outputPackageNames = Get-OutputPackageNames $packages
7979

80+
# Force array in instances of a single package name
81+
if ($outputPackageNames -isnot [array]) {
82+
$outputPackageNames = @($outputPackageNames)
83+
}
84+
8085
[array]$packagesToBuild = $packages | Where-Object { $outputPackageNames.Contains($_.name) }
8186

82-
if ($Release) {
87+
if ($Release) {
8388
return $packagesToBuild
8489
}
8590

@@ -163,22 +168,22 @@ try {
163168

164169
Write-Host "Creating API review file"
165170
$apiReviewFile = Create-ApiViewFile $package
166-
171+
167172
Write-Host "Copying API review file to '$targetApiReviewFile'"
168173
Copy-Item -Path $apiReviewFile -Destination $targetApiReviewFile -Force
169174
}
170175
}
171176

172177
if ($OutBuildOrderFile) {
173178
$buildOrder = @()
174-
foreach ($line in $packResult) {
179+
foreach ($line in $packResult) {
175180
if ($line -match '^\s*Packaging (\w*) ([\w\d\.-]*)') {
176181
$buildOrder += $matches[1]
177182
}
178183
}
179184

180185
Write-Host "Build Order: $($buildOrder -join ', ')"
181-
$buildOrder | ConvertTo-Json -Depth 100 | Set-Content $OutBuildOrderFile
186+
ConvertTo-Json $buildOrder -Depth 100 | Set-Content $OutBuildOrderFile
182187
}
183188
}
184189
finally {

0 commit comments

Comments
 (0)