Debian Codegraph @

node/sync-child-process/dist/lib/index.d.ts

raw
1 import * as stream from 'stream';
2 import { ExitEvent, StderrEvent, StdoutEvent } from './event';
3 export { ExitEvent, StderrEvent, StdoutEvent } from './event';
4 /**
5 * A child process that runs synchronously while also allowing the user to
6 * interact with it before it shuts down.
7 */
8 export declare class SyncChildProcess implements Iterator<StderrEvent | StdoutEvent, ExitEvent | undefined> {
9 /** The port that communicates with the worker thread. */
10 private readonly port;
11 /** The worker in which the child process runs. */
12 private readonly worker;
13 /** The standard input stream to write to the process. */
14 readonly stdin: stream.Writable;
15 /** Creates a new synchronous process running `command` with `args`. */
16 constructor(command: string, options?: Options);
17 constructor(command: string, args: string[], options?: Options);
18 /**
19 * Blocks until the child process is ready to emit another event, then returns
20 * that event. This will return an [IteratorReturnResult] with an [ExitEvent]
21 * once when the process exits. If it's called again after that, it will
22 * return `{done: true}` without a value.
23 *
24 * If there's an error running the child process, this will throw that error.
25 */
26 next(): IteratorResult<StdoutEvent | StderrEvent, ExitEvent | undefined>;
27 /**
28 * Sends a signal (`SIGTERM` by default) to the child process.
29 *
30 * This has no effect if the process has already exited.
31 */
32 kill(signal?: NodeJS.Signals | number): void;
33 /** Closes down the worker thread and the stdin stream. */
34 private close;
35 }
36 /**
37 * A subset of the options for [`child_process.spawn()`].
38 *
39 * [`child_process.spawn()`]: https://nodejs.org/api/child_process.html#child_processspawncommand-args-options
40 */
41 export interface Options {
42 cwd?: string;
43 env?: Record<string, string>;
44 argv0?: string;
45 uid?: number;
46 gid?: number;
47 shell?: boolean | string;
48 windowsVerbatimArguments?: boolean;
49 windowsHide?: boolean;
50 timeout?: number;
51 killSignal?: string | number;
52 }