Skip to content

Latest commit

 

History

History
130 lines (105 loc) · 12.4 KB

File metadata and controls

130 lines (105 loc) · 12.4 KB

Feature documentation

Every feature of command-stream, with executable JavaScript and Rust examples, captured output, and the same thing written with other shell libraries.

This file is generated by node scripts/generate-docs.mjs. Edit the examples in js/examples/features/ or the catalog in js/examples/features/catalog.mjs instead.

Language and runtime parity

All 25 examples were executed in JavaScript and Rust. JavaScript was checked in Node.js and Bun.

Feature JavaScript (Node.js) JavaScript (Bun) Rust
Await a command ✓ ✓ ✓
Read the output with text() ✓ ✓ ✓
Synchronous execution ✓ ✓ ✓
Exit codes and errors ✓ ✓ ✓
Options: capture, cwd, env, stdin ✓ ✓ ✓
Function and builder APIs ✓ ✓ ✓
Killing and cancelling commands ✓ ✓ ✓
Async iteration over output ✓ ✓ ✓
Event-driven output ✓ ✓ ✓
Writing to stdin while a command runs ✓ ✓ ✓
Buffer and string interfaces ✓ ✓ ✓
Mirroring and capturing output ✓ ✓ ✓
The built-in command catalog ✓ ✓ ✓
File system built-ins ✓ ✓ ✓
Text and value built-ins ✓ ✓ ✓
Environment built-ins ✓ ✓ ✓
Registering your own commands ✓ ✓ ✓
The handler context ✓ ✓ ✓
Streaming commands ✓ ✓ ✓
Pipelines ✓ ✓ ✓
Redirecting output and input ✓ ✓ ✓
Command sequences ✓ ✓ ✓
Safe interpolation ✓ ✓ ✓
Shell settings ✓ ✓ ✓
ANSI and control character helpers ✓ ✓ ✓

Library comparison

✓ supported, — not supported. Follow a feature for the code in each library.

Feature command-stream Bun.$ zx execa ShellJS node:child_process
Await a command ✓ ✓ ✓ ✓ ✓ ✓
Read the output with text() ✓ ✓ ✓ ✓ ✓ ✓
Synchronous execution ✓ — ✓ ✓ ✓ ✓
Exit codes and errors ✓ ✓ ✓ ✓ ✓ ✓
Options: capture, cwd, env, stdin ✓ ✓ ✓ ✓ ✓ ✓
Function and builder APIs ✓ — ✓ ✓ ✓ ✓
Killing and cancelling commands ✓ — ✓ ✓ ✓ ✓
Async iteration over output ✓ ✓ ✓ ✓ — ✓
Event-driven output ✓ — ✓ ✓ ✓ ✓
Writing to stdin while a command runs ✓ ✓ ✓ ✓ ✓ ✓
Buffer and string interfaces ✓ ✓ ✓ ✓ — ✓
Mirroring and capturing output ✓ ✓ ✓ ✓ ✓ ✓
The built-in command catalog ✓ ✓ — — ✓ —
File system built-ins ✓ ✓ ✓ — ✓ —
Text and value built-ins ✓ ✓ ✓ ✓ ✓ ✓
Environment built-ins ✓ ✓ ✓ ✓ ✓ ✓
Registering your own commands ✓ — — — ✓ —
The handler context ✓ — — — ✓ —
Streaming commands ✓ — — — — —
Pipelines ✓ ✓ ✓ ✓ ✓ ✓
Redirecting output and input ✓ ✓ ✓ ✓ ✓ ✓
Command sequences ✓ ✓ ✓ — ✓ ✓
Safe interpolation ✓ ✓ ✓ ✓ — ✓
Shell settings ✓ ✓ ✓ — ✓ ✓
ANSI and control character helpers ✓ — ✓ ✓ — —

Features by category

Running commands

Reading output

Streaming

Built-in commands

Your own commands

Shell syntax

  • Pipelines — Commands can be composed into pipelines whose output feeds the next stage.
  • Redirecting output and input — >, >> and < redirect command input and output with shell-compatible behavior.
  • Command sequences — &&, ||, ; and parentheses execute with the expected shell semantics.
  • Safe interpolation — Interpolated values are escaped as arguments; each language also exposes an explicit raw form.
  • Shell settings — Shell settings model errexit, pipefail, verbose, xtrace and nounset behavior.

Utilities

Libraries compared

Library Version Runs in
command-stream this repository Node.js, Bun
Bun.$ 1.4 Bun
zx 8 Node.js, Bun, Deno
execa 9.6 Node.js, Bun, Deno
ShellJS 0.10 Node.js, Bun
node:child_process this repository Node.js, Bun, Deno