UNPKG

ttsc

Version:

General-purpose TypeScript-Go compiler, runtime, plugin host, and LSP host.

30 lines (29 loc) 1.55 kB
import { type SpawnSyncReturns } from "node:child_process"; /** * Spawn a native binary (or a Node.js script when the path has a JS/TS * extension) and return its result with `stdout` and `stderr` as text. * * The child's streams are written to files rather than piped, and the files are * read once it exits. `spawnSync` buffers a _piped_ stream in this process's * memory and refuses to hold more than `maxBuffer` bytes, so a piped capture * has to name a ceiling — and any ceiling is a number nobody chose for this * machine, deciding that a large but legitimate compile said too much. A file * has no such limit: the bytes never pass through this heap on their way out of * the child, and how many there may be is the filesystem's business. * * When `options.encoding` is omitted it defaults to `"utf8"`. Pass `"buffer"` * when the caller needs raw bytes. */ export declare function spawnNative(binary: string, args: readonly string[], options: { cwd?: string; env?: NodeJS.ProcessEnv; encoding?: BufferEncoding | "buffer"; }): SpawnSyncReturns<string | Buffer>; /** * Ensure the binary has the executable bit set on POSIX systems. Silently skips * on Windows and swallows `chmod` errors to let the original spawn error * surface instead of masking it with a permission error. */ export declare function ensureExecutable(binary: string): void; /** Coerce a `spawnSync` output value to a plain string, defaulting to `""`. */ export declare function outputText(value: string | Buffer | null | undefined): string;