/** * Generic process-spawning utilities with timeout handling, * stream cleanup, and discriminated result types. * * Extracted from openNextBuild.ts so other builders can reuse * the same timeout/stream/ENOENT patterns. */ import { spawn } from "child_process"; /** * Result from a spawned process with timeout handling. */ export type SpawnResult = { type: "success"; code: number; stdout: string; stderr: string; } | { type: "timeout"; stdout: string; stderr: string; } | { type: "aborted"; stdout: string; stderr: string; } | { type: "enoent"; error: Error; } | { type: "spawn_error"; error: Error; }; /** * Safely destroy process streams to prevent resource leaks. */ export declare function destroyProcessStreams(childProcess: ReturnType): void; /** * Type guard for ENOENT errors (command not found). */ export declare function isEnoentError(err: unknown): err is NodeJS.ErrnoException; /** * Spawn a child process with timeout handling and stream collection. * * `abortSignal` is the caller's cancellation signal (`DeployParams.abortSignal` * — Ctrl-C, or `fjall deployments cancel`). Without it a cancelled deploy still * waits out the full build timeout, because nothing else can reach the child. */ export declare function spawnWithTimeout(options: { command: string; args: string[]; cwd: string; env: Record; timeout: number; abortSignal?: AbortSignal; onStdoutData?: (data: string) => void; onStderrData?: (data: string) => void; }): Promise;