From a5ac92f21323d706bbeaa46150a3825d95411704 Mon Sep 17 00:00:00 2001 From: Samuel Date: Fri, 22 May 2026 19:02:27 +0200 Subject: [PATCH] Fix parallel native rebuild exit handling --- scripts/build-pointer-release.ps1 | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/scripts/build-pointer-release.ps1 b/scripts/build-pointer-release.ps1 index f882d81d0fd..5ef169924a0 100644 --- a/scripts/build-pointer-release.ps1 +++ b/scripts/build-pointer-release.ps1 @@ -254,6 +254,16 @@ function Invoke-Npm { Invoke-ProcessLogged -Name $Name -FilePath $NpmCmd -Arguments $Arguments -WorkingDirectory $WorkingDirectory } +function ConvertTo-CmdArgument { + param([Parameter(Mandatory = $true)][string]$Argument) + + if ($Argument -notmatch '[\s"]') { + return $Argument + } + + return '"' + ($Argument -replace '"', '\"') + '"' +} + function Start-NpmProcessLogged { param( [Parameter(Mandatory = $true)][string]$Name, @@ -271,13 +281,16 @@ function Start-NpmProcessLogged { Remove-Item -LiteralPath $stdoutPath, $stderrPath, $logPath -Force -ErrorAction SilentlyContinue - $process = Start-Process -FilePath $NpmCmd ` - -ArgumentList $Arguments ` - -WorkingDirectory $WorkingDirectory ` - -RedirectStandardOutput $stdoutPath ` - -RedirectStandardError $stderrPath ` - -PassThru ` - -NoNewWindow + $argumentText = ($Arguments | ForEach-Object { ConvertTo-CmdArgument $_ }) -join ' ' + $command = "`"$NpmCmd`" $argumentText > `"$stdoutPath`" 2> `"$stderrPath`"" + $startInfo = New-Object System.Diagnostics.ProcessStartInfo + $startInfo.FileName = $env:ComSpec + $startInfo.Arguments = "/d /s /c `"$command`"" + $startInfo.WorkingDirectory = $WorkingDirectory + $startInfo.UseShellExecute = $false + $startInfo.CreateNoWindow = $true + + $process = [System.Diagnostics.Process]::Start($startInfo) return [PSCustomObject]@{ Name = $Name