Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

azuki-trusty / azk   deb

Repository URL to install this package:

Version: 0.5.1 

/ usr / lib / azk / node_modules / child-process-promise

  ..
  lib
  node_modules
  README.md
  package.json
  .npmignore
 

child-process-promise

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);
    })
    .fail(function(err) {
        console.error("ERROR: ", err);
    })
    .progress(function(childProcess) {
        console.log('childProcess.pid: ', childProcess.pid);
    });

spawn

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

spawn('echo', ['hello'])
    .progress(function(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()); 
        });
    })
    .then(function(result) {
        console.log('[spawn] done!');
    })
    .fail(function(err) {
        console.error("[spawn] ERROR: ", err);
    });