fix(auto-setup): npm/npx Start-Process 兼容 Windows

Windows 上 Start-Process "npm" 会匹配到无扩展名的 Unix shell 脚本
而非 npm.cmd,导致 "%1 不是有效的 Win32 应用程序" 错误。

在 Run-CmdWithUI 函数入口自动将 npm/npx 映射为 npm.cmd/npx.cmd,
一劳永逸覆盖所有调用点。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Bookworm Bot 2026-04-12 13:59:54 +09:00
parent 9d1cef0331
commit 675606b5c4

View File

@ -237,6 +237,11 @@ function Run-CmdWithUI {
[int]$timeoutMs = 180000, # 默认 3 分钟 [int]$timeoutMs = 180000, # 默认 3 分钟
[switch]$captureOutput # 返回 stdout 内容 [switch]$captureOutput # 返回 stdout 内容
) )
# W-01: Windows Start-Process 兼容 — npm/npx 无扩展名是 Unix shell 脚本
if ($exe -in @("npm", "npx") -and -not $exe.EndsWith(".cmd")) {
$exe = "$exe.cmd"
}
# B1: 脱敏日志 (去除 URL 内嵌凭证 user:pass@) # B1: 脱敏日志 (去除 URL 内嵌凭证 user:pass@)
$sanitizedArgs = ($arguments -join ' ') -replace '://[^@]+@', '://***@' $sanitizedArgs = ($arguments -join ' ') -replace '://[^@]+@', '://***@'
Bw-Log "CMD" "$exe $sanitizedArgs" Bw-Log "CMD" "$exe $sanitizedArgs"