# child-process-async

> The best way to override Node's child_process module w/ Promises

Latest version **1.0.1** (published 2017-07-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install child-process-async
pnpm add child-process-async
yarn add child-process-async
bun add child-process-async
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2017-07-21 |
| First published | 2017-07-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Connor Grady |
| Maintainers | itsjustcon |
| Keywords | child, process, promise, async |

## Links

- npm: https://www.npmjs.com/package/child-process-async
- Repository: https://github.com/itsjustcon/node-child-process-async
- Homepage: https://github.com/itsjustcon/node-child-process-async#readme
- Issues: https://github.com/itsjustcon/node-child-process-async/issues
- npm.io page: https://npm.io/package/child-process-async

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2017-07-21
- 1.0.0 — 2017-07-20

## README

# child-process-async
The best way to override Node's [`child_process`](https://nodejs.org/api/child_process.html) module w/ Promises

`child-process-async` provides a **drop-in replacement** for the original
`child_process` functions, not just duplicate methods that return a Promise.
So when you call `exec(...)` we still return a `ChildProcess` instance, just
with `.then()` and `.catch()` added to it to make it promise-friendly.

## Install
```shell
npm install --save child-process-async
```

## Usage

```js
// OLD:
const { exec, spawn } = require('child_process');
// NEW:
const { exec, spawn } = require('child-process-async');
```

### `exec()`
```js
async function() {
  const { stdout, stderr } = await exec('ls -al');
  // OR:
  const child = await exec('ls -al', {});
  // do whatever you want with `child` here - it's a ChildProcess instance just
  // with promise-friendly `.then()` & `.catch()` functions added to it!
  child.stdin.write(...);
  child.stdout.pipe(...);
  child.stderr.on('data', (data) => ...);
  const { stdout, stderr } = await child;
}
```

### `spawn()`
```js
async function() {
  const { stdout, stderr, exitCode } = await spawn('ls', [ '-al' ]);
  // OR:
  const child = spawn('ls', [ '-al' ], {});
  // do whatever you want with `child` here - it's a ChildProcess instance just
  // with promise-friendly `.then()` & `.catch()` functions added to it!
  child.stdin.write(...);
  child.stdout.pipe(...);
  child.stderr.on('data', (data) => ...);
  const { stdout, stderr, exitCode } = await child;
}
```

---
_Source: https://npm.io/package/child-process-async · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
