Ende.spawn

function · experimental · requires --allow-run

function Ende.spawn(command: string | URL, options?: CommandOptions): ChildProcess

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

Example: Spawn a subprocess

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

function · experimental · requires --allow-run

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

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

Example: Spawn a subprocess with args

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