Compare commits
2
Commits
4361178413
...
3934cedc62
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3934cedc62 | ||
|
|
9e28f3db3f |
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user