StartpodDocs

Run processes

Start commands, stream output, write to stdin, resize terminals, and stop processes.

Use spawn() for supported Node.js commands, npm commands, local package binaries, shells, and development servers.

const process = await startpod.spawn("node", ["script.js"], {
  cwd: startpod.workdir,
  env: { NODE_ENV: "development" },
})

Read output

output combines stdout and stderr in delivery order:

const reader = process.output.getReader()

for (;;) {
  const { value, done } = await reader.read()
  if (done) break
  console.log(value)
}

const exitCode = await process.exit

For supported development-server processes, outputRecords can preserve whether a chunk came from runtime status, stdout, or stderr.

Write input

const writer = process.input.getWriter()
await writer.write("answer\n")
await writer.close()

Stop or resize

process.resize?.({ cols: 120, rows: 32 })
process.kill()

Startpod is not a full desktop operating system. Check compatibility before depending on an arbitrary command or POSIX behavior.

On this page