11#!/usr/bin/env node
22// Routes UI package commands through the repo's Node/pnpm wrappers.
3- import { spawn , spawnSync , type ChildProcess , type SpawnOptions } from "node:child_process" ;
3+ import { spawn , spawnSync , type ChildProcess } from "node:child_process" ;
44import fs from "node:fs" ;
55import { createRequire } from "node:module" ;
66import path from "node:path" ;
@@ -19,11 +19,12 @@ const FORWARDED_SIGNAL_KILL_GRACE_MS = 250;
1919type UiSpawnCall = {
2020 args : string [ ] ;
2121 command : string ;
22- options : SpawnOptions & {
22+ options : {
2323 cwd : string ;
2424 env : NodeJS . ProcessEnv ;
2525 shell : boolean ;
2626 stdio : "inherit" ;
27+ windowsVerbatimArguments ?: boolean ;
2728 } ;
2829} ;
2930
@@ -137,10 +138,11 @@ function runSpawnCall(spawnCall: UiSpawnCall, label: string): void {
137138 return ;
138139 }
139140
140- let forwardedSignal : NodeJS . Signals | null = null ;
141+ const forwardedSignals = [ "SIGTERM" , "SIGHUP" ] as const ;
142+ let forwardedSignal : ( typeof forwardedSignals ) [ number ] | null = null ;
141143 let forwardedSignalPids : number [ ] = [ ] ;
142- let forceKillTimer : NodeJS . Timeout | null = null ;
143- let forwardedSignalDrainTimer : NodeJS . Timeout | null = null ;
144+ let forceKillTimer : ReturnType < typeof setTimeout > | null = null ;
145+ let forwardedSignalDrainTimer : ReturnType < typeof setInterval > | null = null ;
144146 const clearForwardedSignalTimers = ( ) => {
145147 if ( forceKillTimer ) {
146148 clearTimeout ( forceKillTimer ) ;
@@ -166,7 +168,6 @@ function runSpawnCall(spawnCall: UiSpawnCall, label: string): void {
166168 // Keep UI dev children in the foreground process group for native TTY
167169 // resize/job-control behavior. Forward wrapper shutdown signals to the
168170 // captured child tree instead of using a detached process group.
169- const forwardedSignals : NodeJS . Signals [ ] = [ "SIGTERM" , "SIGHUP" ] ;
170171 const signalHandlers = new Map (
171172 forwardedSignals . map ( ( signal ) => [
172173 signal ,
@@ -338,10 +339,6 @@ function resolveScriptAction(action: string): "dev" | "build" | "test" | null {
338339 return null ;
339340}
340341
341- export function assertUiBuildOutputRoot ( params : { rootDir ?: string ; fs ?: typeof fs } = { } ) : void {
342- assertRealOutputRoot ( path . join ( params . rootDir ?? repoRoot , "dist" ) , { fs : params . fs ?? fs } ) ;
343- }
344-
345342function main ( argv : string [ ] = process . argv . slice ( 2 ) ) : void {
346343 const [ action , ...rest ] = argv ;
347344 if ( ! action ) {
@@ -355,7 +352,7 @@ function main(argv: string[] = process.argv.slice(2)): void {
355352 process . exit ( 2 ) ;
356353 }
357354 if ( action === "build" ) {
358- assertUiBuildOutputRoot ( ) ;
355+ assertRealOutputRoot ( path . join ( repoRoot , "dist" ) ) ;
359356 }
360357
361358 if ( process . env . OPENCLAW_BUILD_ALL_NO_PNPM === "1" && action === "build" ) {
0 commit comments