https://github.com/alloc/picospawn
Minimalist `spawn` and `spawnSync` enhancements for Node.js
https://github.com/alloc/picospawn
childprocess nodejs
Last synced: 9 months ago
JSON representation
Minimalist `spawn` and `spawnSync` enhancements for Node.js
- Host: GitHub
- URL: https://github.com/alloc/picospawn
- Owner: alloc
- License: mit
- Created: 2025-04-08T01:58:34.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-04-14T20:09:00.000Z (9 months ago)
- Last Synced: 2025-04-14T20:19:21.880Z (9 months ago)
- Topics: childprocess, nodejs
- Language: TypeScript
- Homepage:
- Size: 40 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# picospawn
Minimalist `spawn` replacement with a focus on simplicity and ease of use.
```
pnpm add picospawn
```
## Usage
```ts
import $ from 'picospawn'
const proc = $('ls -l /', {
// These are the default options.
cwd: process.cwd(),
env: process.env,
stdio: 'pipe',
reject: true,
json: false,
// …and any other `spawn` option.
})
proc.stdout // ReadableStream | null
proc.stderr // ReadableStream | null
const result = await proc
result.stdout // string
result.stderr // string
```
### Features
- Pass a single string or an array of arguments to the command.
- Return a promise that resolves to a `ChildProcess` object.
- Parse the stdout as JSON with `json: true` or `$.json()`.
- Throw an error if the command exits with a non-zero code. Opt-out with `reject: false`.
- Set default options with `$.extend()`.
- Excellent TypeScript support.
- ESM and CommonJS compatible.
- …and more!
## Prior Art
- [tinyspawn](https://github.com/microlinkhq/tinyspawn)