Skip to main content

function Deno.spawnAndWait

unstable
allow-run

Overload 1

#spawnAndWait(
command: string | URL,
options?: CommandOptions,
): Promise<CommandOutput>

Spawns a subprocess, waits for it to finish, and returns the output.

Examples #

#
const { code, stdout, stderr } = await Deno.spawnAndWait(Deno.execPath(), {
  args: ["eval", "console.log('hello')"],
});
console.log(new TextDecoder().decode(stdout)); // "hello\n"

Parameters #

#command: string | URL
#options: CommandOptions
optional

Return Type #

Promise<CommandOutput>

Overload 2

#spawnAndWait(
command: string | URL,
args: string[],
options?: Omit<CommandOptions, "args">,
): Promise<CommandOutput>

Spawns a subprocess with the given arguments, waits for it to finish, and returns the output.

Examples #

#
const { code, stdout } = await Deno.spawnAndWait(
  Deno.execPath(),
  ["eval", "console.log('hello')"],
);
console.log(new TextDecoder().decode(stdout)); // "hello\n"

Parameters #

#command: string | URL
#args: string[]
#options: Omit<CommandOptions, "args">
optional

Return Type #

Promise<CommandOutput>

Did you find what you needed?

Privacy policy