Skip to content

Commit 975b265

Browse files
committed
Refactor output filtering in Get-EvergreenAppFromApi
Changed the output filtering logic to apply Get-FilteredData to each item in $Output using ForEach-Object, instead of filtering the entire collection at once. Also removed sorting and streamlined output handling for clarity.
1 parent 996030a commit 975b265

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

Evergreen/Public/Get-EvergreenAppFromApi.ps1

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ function Get-EvergreenAppFromApi {
2828

2929
# Sort the output
3030
$FilterPath = [System.IO.Path]::Combine((Get-EvergreenAppsPath), "Filters", "$Name.json")
31-
if (Test-Path -Path $FilterPath -PathType "Leaf") {
32-
Write-Verbose -Message "Applying output filter from path: $FilterPath"
33-
$FilteredOutput = Get-FilteredData -InputObject $Output -FilterPath $FilterPath
34-
$FilteredOutput | Sort-Object -Property @{ Expression = { [System.Version]$_.Version }; Descending = $true }, "Ring", "Channel", "Track" -ErrorAction "SilentlyContinue"
35-
Remove-Variable -Name Output -Force -ErrorAction "SilentlyContinue"
36-
}
37-
else {
38-
$Output | Sort-Object -Property @{ Expression = { [System.Version]$_.Version }; Descending = $true }, "Ring", "Channel", "Track" -ErrorAction "SilentlyContinue"
39-
Remove-Variable -Name Output -Force -ErrorAction "SilentlyContinue"
40-
}
31+
if (Test-Path -Path $FilterPath -PathType "Leaf") {
32+
Write-Verbose -Message "Applying output filter from path: $FilterPath"
33+
$Output | ForEach-Object {
34+
Get-FilteredData -InputObject $_ -FilterPath $FilterPath
35+
}
36+
Remove-Variable -Name Output -Force -ErrorAction "SilentlyContinue"
37+
}
38+
else {
39+
$Output
40+
}
4141
}
4242
catch {
4343
throw $_

0 commit comments

Comments
 (0)