Spawn a subprocess, and get buffered output
Deno Sandboxes provide a sandboxed environment for evaluating JavaScript code. This is useful for evaluating code that is not trusted or for testing code that is not safe to run in the main runtime.
You can spawn subprocesses in a sandbox and get buffered output as seen below.
import { Sandbox } from "@deno/sandbox";
await using sandbox = await Sandbox.create();
const text = await sandbox.sh`pwd`.text();
console.log("result:", text); // → "/home/sandbox\n"
For long‑running processes or large output, stream the stdout/stderr.
For more information about Sandboxes, see the Sandboxes documentation.