diff options
author | Leo Kettmeir <crowlkats@toaxl.com> | 2022-11-28 12:33:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-28 12:33:51 +0100 |
commit | 1dd4843b62085a2aeb3134573adf9a7c47c154e2 (patch) | |
tree | 534a7b210655530ffce89b3c124690330867f8bc /cli/tsc | |
parent | fb04e87387e04053bf41a1512b4850adf62202c6 (diff) |
feat(unstable): rework Deno.Command (#16812)
Refactors the `Deno.Command` class to not handle any state, but only being an intermediary to calling its methods, and as such any methods and properties besides `output`, `outputSync` & `spawn` have been removed. Interracting with a `spawn`ed subprocess now works by using the methods and properties on the returned class of the `spawn` method.
Diffstat (limited to 'cli/tsc')
-rw-r--r-- | cli/tsc/diagnostics.rs | 1 | ||||
-rw-r--r-- | cli/tsc/dts/lib.deno.unstable.d.ts | 36 |
2 files changed, 25 insertions, 12 deletions
diff --git a/cli/tsc/diagnostics.rs b/cli/tsc/diagnostics.rs index 05502dca4..4413398c2 100644 --- a/cli/tsc/diagnostics.rs +++ b/cli/tsc/diagnostics.rs @@ -31,6 +31,7 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[ "umask", "spawnChild", "Child", + "ChildProcess", "spawn", "spawnSync", "SpawnOptions", diff --git a/cli/tsc/dts/lib.deno.unstable.d.ts b/cli/tsc/dts/lib.deno.unstable.d.ts index eaa40abc5..ce609736b 100644 --- a/cli/tsc/dts/lib.deno.unstable.d.ts +++ b/cli/tsc/dts/lib.deno.unstable.d.ts @@ -1639,14 +1639,14 @@ declare namespace Deno { * ], * stdin: "piped", * }); - * command.spawn(); + * const child = command.spawn(); * * // open a file and pipe the subprocess output to it. - * command.stdout.pipeTo(Deno.openSync("output").writable); + * child.stdout.pipeTo(Deno.openSync("output").writable); * * // manually close stdin - * command.stdin.close(); - * const status = await command.status; + * child.stdin.close(); + * const status = await child.status; * ``` * * ```ts @@ -1678,13 +1678,6 @@ declare namespace Deno { * @category Sub Process */ export class Command { - get stdin(): WritableStream<Uint8Array>; - get stdout(): ReadableStream<Uint8Array>; - get stderr(): ReadableStream<Uint8Array>; - readonly pid: number; - /** Get the status of the child process. */ - readonly status: Promise<CommandStatus>; - constructor(command: string | URL, options?: CommandOptions); /** * Executes the {@linkcode Deno.Command}, waiting for it to finish and @@ -1711,8 +1704,27 @@ declare namespace Deno { /** * Spawns a streamable subprocess, allowing to use the other methods. */ - spawn(): void; + spawn(): ChildProcess; + } + + /** **UNSTABLE**: New API, yet to be vetted. + * + * The interface for handling a child process returned from + * {@linkcode Deno.Command.spawn}. + * + * @category Sub Process + */ + export class ChildProcess { + get stdin(): WritableStream<Uint8Array>; + get stdout(): ReadableStream<Uint8Array>; + get stderr(): ReadableStream<Uint8Array>; + readonly pid: number; + /** Get the status of the child. */ + readonly status: Promise<CommandStatus>; + /** Waits for the child to exit completely, returning all its output and + * status. */ + output(): Promise<CommandOutput>; /** Kills the process with given {@linkcode Deno.Signal}. Defaults to * `"SIGTERM"`. */ kill(signo?: Signal): void; |