fix(doctor): implement buffered PASS output in summary mode
Implement proper buffering for PASS lines in summary mode: - PASS lines are buffered when -Summary/--summary is active - WARN and FAIL lines print immediately (never buffered) - On success: buffer is discarded, print tally line only - On failure: buffer is flushed before tally line Revert out-of-scope try/catch around Python command (not part of Task 4). Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3fab891383
commit
77dab28c9a
2 files changed
+23
-5
No files matched your search
+12
-3
@@ -6,10 +6,15 @@ $root = Split-Path $PSScriptRoot -Parent
|
||||
$homePath = [Environment]::GetFolderPath('UserProfile')
|
||||
$script:fail = $false
|
||||
$script:checkCount = 0
|
||||
$script:passBuffer = @()
|
||||
function Result($state, $message) {
|
||||
$script:checkCount++
|
||||
if ($state -eq 'FAIL') { $script:fail = $true }
|
||||
if (-not $Summary -or $script:fail -or $state -ne 'PASS') { Write-Output ("$state $message") }
|
||||
if ($Summary -and $state -eq 'PASS') {
|
||||
$script:passBuffer += "$state $message"
|
||||
} else {
|
||||
Write-Output ("$state $message")
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($tool in @('codex','claude')) { if (Get-Command $tool -ErrorAction SilentlyContinue) { $version = & $tool --version 2>&1 | Select-Object -First 1; Result 'PASS' "$tool available ($version)" } else { Result 'WARN' "$tool unavailable" } }
|
||||
@@ -47,7 +52,7 @@ if (Test-Path -LiteralPath $settingsPath) {
|
||||
}
|
||||
$configTomlPath = Join-Path $homePath '.codex/config.toml'
|
||||
if (Test-Path -LiteralPath $configTomlPath) {
|
||||
try { $parseResult = & python -c 'import sys,tomllib,pathlib; tomllib.loads(pathlib.Path(sys.argv[1]).read_text(encoding="utf-8-sig"))' $configTomlPath 2>&1 } catch { $parseResult = $_ }
|
||||
$parseResult = & python -c 'import sys,tomllib,pathlib; tomllib.loads(pathlib.Path(sys.argv[1]).read_text(encoding="utf-8-sig"))' $configTomlPath 2>&1
|
||||
if ($LASTEXITCODE -eq 0) { Result 'PASS' 'installed .codex/config.toml parses as TOML' } else { Result 'FAIL' "installed .codex/config.toml is invalid TOML: $parseResult" }
|
||||
if (Get-Command codex -ErrorAction SilentlyContinue) {
|
||||
$previousCodexHome = $env:CODEX_HOME
|
||||
@@ -83,7 +88,11 @@ foreach ($client in @('codex','claude')) {
|
||||
}
|
||||
|
||||
if ($Summary) {
|
||||
if ($script:fail) { Write-Output "Doctor: FAIL | $script:checkCount checks"; exit 1 }
|
||||
if ($script:fail) {
|
||||
$script:passBuffer | ForEach-Object { Write-Output $_ }
|
||||
Write-Output "Doctor: FAIL | $script:checkCount checks"
|
||||
exit 1
|
||||
}
|
||||
Write-Output "Doctor: PASS | $script:checkCount checks"
|
||||
} else {
|
||||
if ($script:fail) { exit 1 }
|
||||
|
||||
+11
-2
@@ -14,11 +14,16 @@ root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
|
||||
home_path=${HOME:?HOME is required}
|
||||
failed=false
|
||||
check_count=0
|
||||
pass_buffer=()
|
||||
|
||||
result() {
|
||||
check_count=$((check_count + 1))
|
||||
[ "$1" != FAIL ] || failed=true
|
||||
if [ "$summary" = false ] || [ "$failed" = true ] || [ "$1" != PASS ]; then printf '%s %s\n' "$1" "$2"; fi
|
||||
if [ "$summary" = true ] && [ "$1" = PASS ]; then
|
||||
pass_buffer+=("$1 $2")
|
||||
else
|
||||
printf '%s %s\n' "$1" "$2"
|
||||
fi
|
||||
}
|
||||
|
||||
for tool in codex claude; do
|
||||
@@ -96,7 +101,11 @@ for path in shared/rules shared/skills shared/agents shared/hooks/scripts; do
|
||||
done
|
||||
|
||||
if [ "$summary" = true ]; then
|
||||
if [ "$failed" = true ]; then printf 'Doctor: FAIL | %s checks\n' "$check_count"; exit 1; fi
|
||||
if [ "$failed" = true ]; then
|
||||
for line in "${pass_buffer[@]}"; do printf '%s\n' "$line"; done
|
||||
printf 'Doctor: FAIL | %s checks\n' "$check_count"
|
||||
exit 1
|
||||
fi
|
||||
printf 'Doctor: PASS | %s checks\n' "$check_count"
|
||||
else
|
||||
[ "$failed" = false ] || exit 1
|
||||
|
||||
Reference in new issue
Block a user