Skip to main content

function Deno.spawn

unstable
allow-run

Overload 1

#spawn(
command: string | URL,
options?: CommandOptions,
): ChildProcess

Spawns a new subprocess, returning a Deno.ChildProcess handle.

Examples #

#
const child = Deno.spawn(Deno.execPath(), {
  args: ["eval", "console.log('hello')"],
  stdout: "piped",
});
const output = await child.stdout.text();
console.log(output); // "hello\n"
const status = await child.status;

Parameters #

#command: string | URL
#options: CommandOptions
optional

Return Type #

Overload 2

#spawn(
command: string | URL,
args: string[],
options?: Omit<CommandOptions, "args">,
): ChildProcess

Spawns a new subprocess with the given arguments, returning a Deno.ChildProcess handle.

Examples #

#
const child = Deno.spawn(Deno.execPath(), ["eval", "console.log('hello')"], {
  stdout: "piped",
});
const output = await child.stdout.text();
console.log(output); // "hello\n"
const status = await child.status;

Parameters #

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

Return Type #

Did you find what you needed?

Privacy policy