Skip to main content
当使用 Bun.spawn() 时,子进程的 stdout 可以通过 proc.stdout 作为 ReadableStream 来消费。
const proc = Bun.spawn(["echo", "hello"]);

const output = await proc.stdout.text();
output; // => "hello"

要将子进程的 stdout 传输到父进程的 stdout,请设置为 “inherit”。
const proc = Bun.spawn(["echo", "hello"], {
  stdout: "inherit",
});

请参阅 文档 > API > 子进程 以获取完整文档。