Skip to content

Commit 6e3ea69

Browse files
committed
✨ [feat] Improves Build-ColorScriptCache function
✨ [feat] Enhances `Build-ColorScriptCache` function to streamline output and `PassThru` behavior. - 🔄 Modifies the logic to return results immediately when `-PassThru` is specified, improving efficiency. - 💬 Adjusts the summary display to only occur when `-PassThru` is not used and there are results, preventing unnecessary output. - 🧹 Simplifies the code by removing redundant `-PassThru` check, leading to a cleaner and more maintainable structure. Signed-off-by: Nick2bad4u <20943337+Nick2bad4u@users.noreply.github.com>
1 parent 85c68b7 commit 6e3ea69

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

ColorScripts-Enhanced/ColorScripts-Enhanced.psm1

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,8 +1401,13 @@ function Build-ColorScriptCache {
14011401

14021402
Write-Progress -Id 1 -Activity $progressActivity -Completed
14031403

1404-
# Display summary unless PassThru is specified
1405-
if (-not $PassThru -and $totalCount -gt 0) {
1404+
# Return results if PassThru is specified
1405+
if ($PassThru) {
1406+
return [pscustomobject[]]$results
1407+
}
1408+
1409+
# Display summary if not using PassThru and there are results
1410+
if ($totalCount -gt 0) {
14061411
$summary = $results | Group-Object -Property Status | ForEach-Object {
14071412
[pscustomobject]@{
14081413
Status = $_.Name
@@ -1442,10 +1447,6 @@ function Build-ColorScriptCache {
14421447
Write-Host "`nTotal scripts processed: $totalCount" -ForegroundColor Cyan
14431448
Write-Host "Use -PassThru to see detailed results`n" -ForegroundColor Gray
14441449
}
1445-
1446-
if ($PassThru) {
1447-
return [pscustomobject[]]$results
1448-
}
14491450
}
14501451
}
14511452

0 commit comments

Comments
 (0)