2 Commits
Author SHA1 Message Date
Danila KhodjaefandCursor 3934cedc62 Fix devtoprod validateBuild exit-code handling
Ensure Invoke-Npm returns correct exit code without breaking step logic.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-08 17:46:56 +03:00
Danila KhodjaefandCursor 9e28f3db3f Fix validateBuild failing due to npm output capture
Ensure Invoke-Npm streams output to host and returns only exit code.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-08 17:32:49 +03:00
+19 -4
View File
@@ -50,12 +50,26 @@ function Get-StepEnabled {
function Invoke-Npm { function Invoke-Npm {
param([string]$Script, [string[]]$ExtraArgs = @()) param([string]$Script, [string[]]$ExtraArgs = @())
$args = @('run', $Script) $npmArgs = @('run', $Script)
if ($ExtraArgs.Count -gt 0) { if ($ExtraArgs.Count -gt 0) {
$args += '--' $npmArgs += '--'
$args += $ExtraArgs $npmArgs += $ExtraArgs
}
# Important: callers assign the return value of this function to a variable
# (e.g. `$code = Invoke-Npm 'prod:build'`).
# If npm output is sent to the pipeline, PowerShell can accidentally capture
# stdout/stderr along with the function return value, breaking exit-code logic.
# So we stream npm output to $null and return only the exit code.
Write-Host ("Running npm: npm " + ($npmArgs -join ' ')) -ForegroundColor DarkGray
# Capture stdout/stderr so the function does not emit pipeline output.
$prevEap = $ErrorActionPreference
$ErrorActionPreference = 'Continue'
$npmOutput = & npm @npmArgs 2>&1
$ErrorActionPreference = $prevEap
foreach ($line in $npmOutput) {
Write-Host $line
} }
& npm @args
return $LASTEXITCODE return $LASTEXITCODE
} }
@@ -245,6 +259,7 @@ Write-Host ('Steps: ' + ($enabled -join ', '))
if (Get-StepEnabled $steps 'validateBuild') { if (Get-StepEnabled $steps 'validateBuild') {
$ok = Invoke-Step 'validateBuild' { $ok = Invoke-Step 'validateBuild' {
$code = Invoke-Npm 'prod:build' $code = Invoke-Npm 'prod:build'
Write-Host ("prod:build exit code: " + $code)
if ($code -ne 0) { return $code } if ($code -ne 0) { return $code }
# Always prefer the dev host on LAN (192.168.10.70) because the HTTPS dev domain # Always prefer the dev host on LAN (192.168.10.70) because the HTTPS dev domain