child-process-promise
Simple wrapper around the "child_process" module that makes use of promises
Last updated 3 years ago by pnidem .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install child-process-promise 
SYNC missed versions from official npm registry.

child-process-promise

Build Status NPM Downloads

Simple wrapper around the child_process module that makes use of promises

Installation

npm install child-process-promise --save

Usage

exec

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

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

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);
    });

Current Tags

  • 2.2.1                                ...           latest (3 years ago)
  • 0.2.0-SNAPSHOT.1389671754086                                ...           v0_2_0-SNAPSHOT (6 years ago)

19 Versions

  • 2.2.1                                ...           3 years ago
  • 2.2.0                                ...           3 years ago
  • 2.1.3                                ...           3 years ago
  • 2.1.2                                ...           3 years ago
  • 2.1.1                                ...           3 years ago
  • 2.1.0                                ...           3 years ago
  • 2.0.3                                ...           3 years ago
  • 2.0.2                                ...           3 years ago
  • 2.0.1                                ...           4 years ago
  • 2.0.0                                ...           4 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.2                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
  • 0.2.0-SNAPSHOT.1389671754086                                ...           6 years ago
  • 0.1.3                                ...           6 years ago
  • 0.2.0-SNAPSHOT.1384371455574                                ...           6 years ago
  • 0.1.1                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
Downloads
Today 2
This Week 515
This Month 1,155
Last Day 70
Last Week 521
Last Month 2,379
Dependencies (3)
Dev Dependencies (8)
Dependents (683)

Copyright 2014 - 2016 © taobao.org |