fix(#48): stop the launcher turning child stderr into PowerShell errors

The remaining red block came from go-admin's own "config init" line. That
is the third informational stderr writer to surface this way, and the
first two were only fixed by silencing them one at a time — the actual
defect is in the launcher, not in any of the writers.

`2>&1 |` makes PowerShell wrap every stderr line from a native command in
an ErrorRecord, which renders as a NativeCommandError block and reads as
a failed migration regardless of what the line says. Stringifying in the
pipeline fixes the whole class, including SDK output this repo cannot
change.

Verified in Windows PowerShell from WSL: the bare pipeline produces the
red block for a plain stderr line while the stringified one does not, and
$LASTEXITCODE still reports the child's exit code (3) through the extra
stage, so the migration failure check below is unaffected. Script
parse-checked and run with -ValidateConfigOnly.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
QiuSW
2026-08-20 10:01:37 +08:00
co-authored by Claude Opus 5
parent 1d9dbfda76
commit a81d60523d
+9
View File
@@ -228,7 +228,16 @@ try {
$previousErrorActionPreference = $ErrorActionPreference
try {
$ErrorActionPreference = "Continue"
# Stringify before Tee-Object. With a bare `2>&1 |`, PowerShell wraps
# every line the child writes to stderr in an ErrorRecord, which prints
# as a red NativeCommandError block and reads as a failed migration --
# even for ordinary informational output such as go-admin's
# "config init". Chasing individual stderr writers is whack-a-mole; this
# fixes the whole class. $LASTEXITCODE still reports the child's real
# exit code through the added pipeline stage, so failure detection below
# is unaffected.
& go run . migrate -c config/settings.yml 2>&1 |
ForEach-Object { "$_" } |
Tee-Object -FilePath $migrationLog
$migrationExitCode = $LASTEXITCODE
}