# child-process-promise

> Simple wrapper around the "child_process" module that makes use of promises

Latest version **2.2.1** (published 2017-03-29) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.1 |
| Published | 2017-03-29 |
| First published | 2013-08-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/child-process-promise) |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 247 |
| Author | Patrick Steele-Idem |
| Maintainers | psteeleidem, pnidem |
| Keywords | child, process, promises |

## Links

- npm: https://www.npmjs.com/package/child-process-promise
- Repository: https://github.com/patrick-steele-idem/child-process-promise
- Homepage: https://github.com/patrick-steele-idem/child-process-promise#readme
- Issues: https://github.com/patrick-steele-idem/child-process-promise/issues
- npm.io page: https://npm.io/package/child-process-promise

## Dependencies (3)

- [cross-spawn](https://npm.io/package/cross-spawn.md) ^4.0.2
- [node-version](https://npm.io/package/node-version.md) ^1.0.0
- [promise-polyfill](https://npm.io/package/promise-polyfill.md) ^6.0.1

## 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

- 2.2.1 (latest) — 2017-03-29
- 0.2.0-SNAPSHOT.1389671754086 (v0_2_0-SNAPSHOT) — 2014-01-14
- 2.2.0 — 2016-10-31
- 2.1.3 — 2016-08-19
- 2.1.2 — 2016-08-16
- 2.1.1 — 2016-08-15
- 2.1.0 — 2016-08-12
- 2.0.3 — 2016-06-20
- 2.0.2 — 2016-05-04
- 2.0.1 — 2016-04-11
- 2.0.0 — 2016-04-11
- 1.1.0 — 2015-05-15
- 1.0.2 — 2015-03-23
- 1.0.1 — 2014-12-18
- 1.0.0 — 2014-10-07
- … 4 more at https://npm.io/package/child-process-promise/versions

## README

child-process-promise
=====================

[![Build Status](https://travis-ci.org/patrick-steele-idem/child-process-promise.svg?branch=master)](https://travis-ci.org/patrick-steele-idem/child-process-promise)
[![NPM](https://img.shields.io/npm/v/child-process-promise.svg)](https://www.npmjs.com/package/child-process-promise)
[![Downloads](https://img.shields.io/npm/dm/child-process-promise.svg)](http://npm-stat.com/charts.html?package=child-process-promise)

Simple wrapper around the `child_process` module that makes use of promises

# Installation
```
npm install child-process-promise --save
```

# Usage

## exec
```javascript
var exec = require('child-process-promise').exec;

exec('echo hello')
    .then(function (result) {
        var stdout = result.stdout;
        var stderr = result.stderr;
        console.log('stdout: ', stdout);
        console.log('stderr: ', stderr);
    })
    .catch(function (err) {
        console.error('ERROR: ', err);
    });
```

## spawn
```javascript
var spawn = require('child-process-promise').spawn;

var promise = spawn('echo', ['hello']);

var childProcess = promise.childProcess;

console.log('[spawn] childProcess.pid: ', childProcess.pid);
childProcess.stdout.on('data', function (data) {
    console.log('[spawn] stdout: ', data.toString());
});
childProcess.stderr.on('data', function (data) {
    console.log('[spawn] stderr: ', data.toString());
});

promise.then(function () {
        console.log('[spawn] done!');
    })
    .catch(function (err) {
        console.error('[spawn] ERROR: ', err);
    });
```
### Options

#### capture
Type: `Array`  
Default: `[]`

Pass an additional `capture` option to buffer the result of `stdout` and/or `stderr`

```javascript
var spawn = require('child-process-promise').spawn;

spawn('echo', ['hello'], { capture: [ 'stdout', 'stderr' ]})
    .then(function (result) {
        console.log('[spawn] stdout: ', result.stdout.toString());
    })
    .catch(function (err) {
        console.error('[spawn] stderr: ', err.stderr);
    });
```

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