• Stars
    star
    250
  • Rank 162,397 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 11 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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

More Repositories

1

morphdom

Fast and lightweight DOM diffing/patching (no virtual DOM needed)
JavaScript
3,165
star
2

app-module-path-node

Simple module to add additional directories to the Node module search for top-level app modules
JavaScript
411
star
3

browser-refresh

Node.js module to enable server restart and browser refresh in response to file modifications
JavaScript
110
star
4

marko-vs-react

DEPRECATED - Test app to benchmark and compare Marko and React
HTML
90
star
5

warp10

Transport complex/circular JavaScript objects from the server to the web browser at lightning fast speeds
JavaScript
46
star
6

codemirror-atom-modes

Use Atom grammar files to apply syntax highlighting in a CodeMirror editor
JavaScript
16
star
7

warmup

Warmup server apps by hitting URLs or performing tasks.
JavaScript
12
star
8

require-self-ref

Solves the relative path problem in Node.js by allowing the target module argument of a require call to be relative to the root directory of the containing package
JavaScript
11
star
9

meta-router

Declarative URL router for Express that provides support for associating metadata with a route.
JavaScript
11
star
10

http-stats

Node.js module for benchmarking HTTP servers
JavaScript
7
star
11

listener-tracker

Allows added event listeners to be tracked for easy removal
JavaScript
7
star
12

express-view-streaming

Sample app that demonstrates streaming template rendering with Express
JavaScript
7
star
13

argly

A flexible command line arguments parser that is easy to configure and offers robust type handling.
JavaScript
7
star
14

async-config

A simple Node.js module for loading environment-specific config files.
JavaScript
6
star
15

express-resetter

Utility module to reset an Express instance to a previous state after registering middleware
JavaScript
6
star
16

browser-refresh-taglib

Taglib to enable browser page refresh in response to file modifications on the server
JavaScript
4
star
17

ignoring-watcher

Watch an entire directory tree while ignoring specific directories/files based on .gitignore rules.
JavaScript
4
star
18

browser-refresh-client

Small module to interface with the parent browser-refresh process to control reloading
JavaScript
3
star
19

events-light

Lightweight and fast implementation of the 'events' module for the browser and server
JavaScript
3
star
20

github-project-inspector

Node.js module that uses the Github API to gather metadata about a project on Github
JavaScript
2
star
21

velociblog

A static blog generator built on top of JavaScript, Node.js and RaptorJS
JavaScript
1
star
22

dynamically-generated-static-site

Sample dynamically generated static site
CSS
1
star
23

marko-async-fragment-wrapper

JavaScript
1
star
24

nodejs-training

JavaScript
1
star
25

ghcrawler-in-a-box

Easily start ghcrawler
JavaScript
1
star
26

property-handlers

Utility for mapping object properties to handler functions
JavaScript
1
star
27

deresolve

The inverse of require.resolve()
JavaScript
1
star
28

raptorjs3-kraken-sample-app

JavaScript
1
star