Skip to main content

function Deno.spawnAndWaitSync

unstable
allow-run

Overload 1

#spawnAndWaitSync(
command: string | URL,
options?: CommandOptions,
): CommandOutput

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

Examples #

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

Parameters #

#command: string | URL
#options: CommandOptions
optional

Return Type #

Overload 2

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

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

Examples #

#
const { code, stdout } = Deno.spawnAndWaitSync(
  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 #

Did you find what you needed?

Privacy policy