mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-25 06:24:27 +08:00
* feat(child_process): support writable child stdin - Add nonblocking child stdin writers with lifecycle events and platform-aware backpressure. - Lower writable streams through the C and LLVM backends while fencing unsupported overloads. - Add differential, type, diagnostics, and compatibility coverage. Fixes #311 Co-authored-by: euxaristia <25621994+euxaristia@users.noreply.github.com> * Reject non-literal spawn options - Emit a named lowering diagnostic instead of silently dropping variable options. - Cover two- and three-argument spawn overloads with diagnostic regressions. Fixes #311 Co-authored-by: euxaristia <25621994+euxaristia@users.noreply.github.com> --------- Co-authored-by: euxaristia <25621994+euxaristia@users.noreply.github.com>
30 lines
1.3 KiB
TypeScript
30 lines
1.3 KiB
TypeScript
// child_process support boundaries: what stays rejected at LOWERING with
|
|
// specific messages. The fallback declarations type the supported surface
|
|
// exactly, so most misuse is a type error before lowering; these are the
|
|
// forms that TYPECHECK and fence per site.
|
|
|
|
import { spawn } from "node:child_process";
|
|
|
|
// The default and explicit "pipe" forms use piped streams.
|
|
// Keep both adjacent to the remaining rejection cases.
|
|
const noOpts = spawn("/bin/echo");
|
|
|
|
// "inherit" and "ignore" remain process-only forms without child streams.
|
|
// All four supported modes must coexist with the fences below.
|
|
const piped = spawn("/bin/echo", [], { stdio: "pipe" });
|
|
const inherited = spawn("/bin/echo", [], { stdio: "inherit" });
|
|
|
|
// A variable options value must fence instead of being dropped.
|
|
const options: { stdio: "ignore"; detached: boolean } = { stdio: "ignore", detached: true };
|
|
spawn("true", [], options);
|
|
const c = spawn("true", [], { stdio: "ignore" });
|
|
|
|
// `() => 5` IS assignable to a void-returning listener slot and now ADOPTS
|
|
// the slot's void (JS ignores the value); an ANNOTATED value-returning
|
|
// listener keeps its word and stays fenced — the registry calls listeners
|
|
// as void.
|
|
c.on("exit", (): number => 5);
|
|
// Methods have no bound-value form — call on directly.
|
|
const f = c.on;
|
|
// Keep each fence on its own statement so diagnostics remain site-specific.
|