生成子进程,并获取缓冲输出
Deno Sandbox provides a sandboxed Linux microVM. This is useful for evaluating code that is not trusted or for testing code that is not safe to run in your main runtime.
你可以在沙箱中生成子进程,并获取缓冲输出,如下所示。
import { Sandbox } from "@deno/sandbox";
await using sandbox = await Sandbox.create();
const cwd = await sandbox.sh`pwd`;
对于长时间运行的进程或大量输出,可以使用 stdout/stderr 流。
For more information, see the Deno Sandbox documentation.