Process execution for humans: run subprocesses from Node.js without shell escaping
open sourceMITfree
Execa runs subprocesses from Node.js with promises and template strings and no escaping or quoting, so there's no risk of shell injection. It runs locally installed binaries without npx, improves Windows support (shebangs, PATHEXT, graceful termination), gives detailed errors and a verbose mode, and pipes several subprocesses together better than a shell does, keeping each step's result. Output can be split into lines or iterated as it arrives, interleaved from stdout and stderr, transformed with simple functions, or passed as Node.js or web streams, and subprocesses are made to exit even when they ignore termination signals. It's by Sindre Sorhus.
Problems it solves
- run a shell command from my Node script without worrying about quoting and injection
- pipe the output of one command into another from JavaScript and keep both results
- my child_process spawn code breaks on Windows
Features
- promise and template string syntax with no escaping or shell injection
- runs locally installed binaries without npx
- Windows support for shebangs, PATHEXT and graceful termination
- piping between subprocesses with intermediate results
- line splitting, interleaved stdout and stderr, and transforms
- Node.js and web streams in and out
- forceful termination when a subprocess ignores signals
Alternatives
The same job
These do what Execa does.
- cross-spawn Cross-platform child_process spawn and spawnSync for Node.js
