Ende.spawnAndWaitSync

function · experimental · requires --allow-run

function Ende.spawnAndWaitSync(command: string | URL, options?: CommandOptions): CommandOutput

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

Example: Spawn and wait synchronously

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

function · experimental · requires --allow-run

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

Example: Spawn and wait synchronously with args

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