Ende.spawnAndWait

function · experimental · requires --allow-run

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

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

Example: Spawn and wait for output

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

function · experimental · requires --allow-run

function Ende.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.

Example: Spawn and wait with args

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