diff options
Diffstat (limited to 'cli/tsc')
-rw-r--r-- | cli/tsc/diagnostics.rs | 9 | ||||
-rw-r--r-- | cli/tsc/dts/lib.deno.ns.d.ts | 212 | ||||
-rw-r--r-- | cli/tsc/dts/lib.deno.unstable.d.ts | 218 |
3 files changed, 212 insertions, 227 deletions
diff --git a/cli/tsc/diagnostics.rs b/cli/tsc/diagnostics.rs index 461cda775..a865daa9d 100644 --- a/cli/tsc/diagnostics.rs +++ b/cli/tsc/diagnostics.rs @@ -29,15 +29,6 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[ "removeSignalListener", "shutdown", "umask", - "Child", - "ChildProcess", - "ChildStatus", - "SpawnOutput", - "command", - "Command", - "CommandOptions", - "CommandStatus", - "CommandOutput", "serve", "ServeInit", "ServeTlsInit", diff --git a/cli/tsc/dts/lib.deno.ns.d.ts b/cli/tsc/dts/lib.deno.ns.d.ts index d81e4afcd..93e1b54a6 100644 --- a/cli/tsc/dts/lib.deno.ns.d.ts +++ b/cli/tsc/dts/lib.deno.ns.d.ts @@ -3958,6 +3958,218 @@ declare namespace Deno { */ export function run<T extends RunOptions = RunOptions>(opt: T): Process<T>; + /** Create a child process. + * + * If any stdio options are not set to `"piped"`, accessing the corresponding + * field on the `Command` or its `CommandOutput` will throw a `TypeError`. + * + * If `stdin` is set to `"piped"`, the `stdin` {@linkcode WritableStream} + * needs to be closed manually. + * + * @example Spawn a subprocess and pipe the output to a file + * + * ```ts + * const command = new Deno.Command(Deno.execPath(), { + * args: [ + * "eval", + * "console.log('Hello World')", + * ], + * stdin: "piped", + * }); + * const child = command.spawn(); + * + * // open a file and pipe the subprocess output to it. + * child.stdout.pipeTo(Deno.openSync("output").writable); + * + * // manually close stdin + * child.stdin.close(); + * const status = await child.status; + * ``` + * + * @example Spawn a subprocess and collect its output + * + * ```ts + * const command = new Deno.Command(Deno.execPath(), { + * args: [ + * "eval", + * "console.log('hello'); console.error('world')", + * ], + * }); + * const { code, stdout, stderr } = await command.output(); + * console.assert(code === 0); + * console.assert("hello\n" === new TextDecoder().decode(stdout)); + * console.assert("world\n" === new TextDecoder().decode(stderr)); + * ``` + * + * @example Spawn a subprocess and collect its output synchronously + * + * ```ts + * const command = new Deno.Command(Deno.execPath(), { + * args: [ + * "eval", + * "console.log('hello'); console.error('world')", + * ], + * }); + * const { code, stdout, stderr } = command.outputSync(); + * console.assert(code === 0); + * console.assert("hello\n" === new TextDecoder().decode(stdout)); + * console.assert("world\n" === new TextDecoder().decode(stderr)); + * ``` + * + * @category Sub Process + */ + export class Command { + constructor(command: string | URL, options?: CommandOptions); + /** + * Executes the {@linkcode Deno.Command}, waiting for it to finish and + * collecting all of its output. + * If `spawn()` was called, calling this function will collect the remaining + * output. + * + * Will throw an error if `stdin: "piped"` is set. + * + * If options `stdout` or `stderr` are not set to `"piped"`, accessing the + * corresponding field on {@linkcode Deno.CommandOutput} will throw a `TypeError`. + */ + output(): Promise<CommandOutput>; + /** + * Synchronously executes the {@linkcode Deno.Command}, waiting for it to + * finish and collecting all of its output. + * + * Will throw an error if `stdin: "piped"` is set. + * + * If options `stdout` or `stderr` are not set to `"piped"`, accessing the + * corresponding field on {@linkcode Deno.CommandOutput} will throw a `TypeError`. + */ + outputSync(): CommandOutput; + /** + * Spawns a streamable subprocess, allowing to use the other methods. + */ + spawn(): ChildProcess; + } + + /** + * 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}. + * + * @param [signo="SIGTERM"] + */ + kill(signo?: Signal): void; + + /** Ensure that the status of the child process prevents the Deno process + * from exiting. */ + ref(): void; + /** Ensure that the status of the child process does not block the Deno + * process from exiting. */ + unref(): void; + } + + /** + * Options which can be set when calling {@linkcode Deno.Command}. + * + * @category Sub Process + */ + export interface CommandOptions { + /** Arguments to pass to the process. */ + args?: string[]; + /** + * The working directory of the process. + * + * If not specified, the `cwd` of the parent process is used. + */ + cwd?: string | URL; + /** + * Clear environmental variables from parent process. + * + * Doesn't guarantee that only `env` variables are present, as the OS may + * set environmental variables for processes. + * + * @default {false} + */ + clearEnv?: boolean; + /** Environmental variables to pass to the subprocess. */ + env?: Record<string, string>; + /** + * Sets the child process’s user ID. This translates to a setuid call in the + * child process. Failure in the set uid call will cause the spawn to fail. + */ + uid?: number; + /** Similar to `uid`, but sets the group ID of the child process. */ + gid?: number; + /** + * An {@linkcode AbortSignal} that allows closing the process using the + * corresponding {@linkcode AbortController} by sending the process a + * SIGTERM signal. + * + * Not supported in {@linkcode Deno.Command.outputSync}. + */ + signal?: AbortSignal; + + /** How `stdin` of the spawned process should be handled. + * + * Defaults to `"inherit"` for `output` & `outputSync`, + * and `"inherit"` for `spawn`. */ + stdin?: "piped" | "inherit" | "null"; + /** How `stdout` of the spawned process should be handled. + * + * Defaults to `"piped"` for `output` & `outputSync`, + * and `"inherit"` for `spawn`. */ + stdout?: "piped" | "inherit" | "null"; + /** How `stderr` of the spawned process should be handled. + * + * Defaults to `"piped"` for `output` & `outputSync`, + * and `"inherit"` for `spawn`. */ + stderr?: "piped" | "inherit" | "null"; + + /** Skips quoting and escaping of the arguments on windows. This option + * is ignored on non-windows platforms. + * + * @default {false} */ + windowsRawArguments?: boolean; + } + + /** + * @category Sub Process + */ + export interface CommandStatus { + /** If the child process exits with a 0 status code, `success` will be set + * to `true`, otherwise `false`. */ + success: boolean; + /** The exit code of the child process. */ + code: number; + /** The signal associated with the child process. */ + signal: Signal | null; + } + + /** + * The interface returned from calling {@linkcode Command.output} or + * {@linkcode Command.outputSync} which represents the result of spawning the + * child process. + * + * @category Sub Process + */ + export interface CommandOutput extends CommandStatus { + /** The buffered output from the child process' `stdout`. */ + readonly stdout: Uint8Array; + /** The buffered output from the child process' `stderr`. */ + readonly stderr: Uint8Array; + } + /** Option which can be specified when performing {@linkcode Deno.inspect}. * * @category Console and Debugging */ diff --git a/cli/tsc/dts/lib.deno.unstable.d.ts b/cli/tsc/dts/lib.deno.unstable.d.ts index 898343d80..e2abab26d 100644 --- a/cli/tsc/dts/lib.deno.unstable.d.ts +++ b/cli/tsc/dts/lib.deno.unstable.d.ts @@ -1409,224 +1409,6 @@ declare namespace Deno { /** **UNSTABLE**: New API, yet to be vetted. * - * Create a child process. - * - * If any stdio options are not set to `"piped"`, accessing the corresponding - * field on the `Command` or its `CommandOutput` will throw a `TypeError`. - * - * If `stdin` is set to `"piped"`, the `stdin` {@linkcode WritableStream} - * needs to be closed manually. - * - * @example Spawn a subprocess and pipe the output to a file - * - * ```ts - * const command = new Deno.Command(Deno.execPath(), { - * args: [ - * "eval", - * "console.log('Hello World')", - * ], - * stdin: "piped", - * }); - * const child = command.spawn(); - * - * // open a file and pipe the subprocess output to it. - * child.stdout.pipeTo(Deno.openSync("output").writable); - * - * // manually close stdin - * child.stdin.close(); - * const status = await child.status; - * ``` - * - * @example Spawn a subprocess and collect its output - * - * ```ts - * const command = new Deno.Command(Deno.execPath(), { - * args: [ - * "eval", - * "console.log('hello'); console.error('world')", - * ], - * }); - * const { code, stdout, stderr } = await command.output(); - * console.assert(code === 0); - * console.assert("hello\n" === new TextDecoder().decode(stdout)); - * console.assert("world\n" === new TextDecoder().decode(stderr)); - * ``` - * - * @example Spawn a subprocess and collect its output synchronously - * - * ```ts - * const command = new Deno.Command(Deno.execPath(), { - * args: [ - * "eval", - * "console.log('hello'); console.error('world')", - * ], - * }); - * const { code, stdout, stderr } = command.outputSync(); - * console.assert(code === 0); - * console.assert("hello\n" === new TextDecoder().decode(stdout)); - * console.assert("world\n" === new TextDecoder().decode(stderr)); - * ``` - * - * @category Sub Process - */ - export class Command { - constructor(command: string | URL, options?: CommandOptions); - /** - * Executes the {@linkcode Deno.Command}, waiting for it to finish and - * collecting all of its output. - * If `spawn()` was called, calling this function will collect the remaining - * output. - * - * Will throw an error if `stdin: "piped"` is set. - * - * If options `stdout` or `stderr` are not set to `"piped"`, accessing the - * corresponding field on {@linkcode Deno.CommandOutput} will throw a `TypeError`. - */ - output(): Promise<CommandOutput>; - /** - * Synchronously executes the {@linkcode Deno.Command}, waiting for it to - * finish and collecting all of its output. - * - * Will throw an error if `stdin: "piped"` is set. - * - * If options `stdout` or `stderr` are not set to `"piped"`, accessing the - * corresponding field on {@linkcode Deno.CommandOutput} will throw a `TypeError`. - */ - outputSync(): CommandOutput; - /** - * Spawns a streamable subprocess, allowing to use the other methods. - */ - 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}. - * - * @param [signo="SIGTERM"] - */ - kill(signo?: Signal): void; - - /** Ensure that the status of the child process prevents the Deno process - * from exiting. */ - ref(): void; - /** Ensure that the status of the child process does not block the Deno - * process from exiting. */ - unref(): void; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Options which can be set when calling {@linkcode Deno.command}. - * - * @category Sub Process - */ - export interface CommandOptions { - /** Arguments to pass to the process. */ - args?: readonly string[]; - /** - * The working directory of the process. - * - * If not specified, the `cwd` of the parent process is used. - */ - cwd?: string | URL; - /** - * Clear environmental variables from parent process. - * - * Doesn't guarantee that only `env` variables are present, as the OS may - * set environmental variables for processes. - * - * @default {false} - */ - clearEnv?: boolean; - /** Environmental variables to pass to the subprocess. */ - env?: Record<string, string>; - /** - * Sets the child process’s user ID. This translates to a setuid call in the - * child process. Failure in the set uid call will cause the spawn to fail. - */ - uid?: number; - /** Similar to `uid`, but sets the group ID of the child process. */ - gid?: number; - /** - * An {@linkcode AbortSignal} that allows closing the process using the - * corresponding {@linkcode AbortController} by sending the process a - * SIGTERM signal. - * - * Not supported in {@linkcode Deno.Command.outputSync}. - */ - signal?: AbortSignal; - - /** How `stdin` of the spawned process should be handled. - * - * Defaults to `"inherit"` for `output` & `outputSync`, - * and `"inherit"` for `spawn`. */ - stdin?: "piped" | "inherit" | "null"; - /** How `stdout` of the spawned process should be handled. - * - * Defaults to `"piped"` for `output` & `outputSync`, - * and `"inherit"` for `spawn`. */ - stdout?: "piped" | "inherit" | "null"; - /** How `stderr` of the spawned process should be handled. - * - * Defaults to `"piped"` for `output` & `outputSync`, - * and `"inherit"` for `spawn`. */ - stderr?: "piped" | "inherit" | "null"; - - /** Skips quoting and escaping of the arguments on windows. This option - * is ignored on non-windows platforms. - * - * @default {false} */ - windowsRawArguments?: boolean; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * @category Sub Process - */ - export interface CommandStatus { - /** If the child process exits with a 0 status code, `success` will be set - * to `true`, otherwise `false`. */ - success: boolean; - /** The exit code of the child process. */ - code: number; - /** The signal associated with the child process. */ - signal: Signal | null; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * - * The interface returned from calling {@linkcode Command.output} or - * {@linkcode Command.outputSync} which represents the result of spawning the - * child process. - * - * @category Sub Process - */ - export interface CommandOutput extends CommandStatus { - /** The buffered output from the child process' `stdout`. */ - readonly stdout: Uint8Array; - /** The buffered output from the child process' `stderr`. */ - readonly stderr: Uint8Array; - } - - /** **UNSTABLE**: New API, yet to be vetted. - * * Returns the Operating System uptime in number of seconds. * * ```ts |