buffered-spawn
Buffered child process#spawn.
Last updated 9 years ago by satazor .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install buffered-spawn 
SYNC missed versions from official npm registry.

buffered-spawn

NPM version Downloads Build Status Dependency status Dev Dependency status

Buffered child_process#spawn.

Installation

$ npm install buffered-spawn

Why

  • Easy to use
  • Uses cross-spawn by default, which fixes windows issues
  • Supports callback & promise style

Usage

In terms of arguments, they are equal to node's spawn.

const bufferedSpawn = require('buffered-spawn');

// Callback style
bufferedSpawn('git', ['clone', 'git@github.com/bower/bower'], { cwd: '.' }, (err, stdout, stderr) => {
    if (err) {
        // Both stdout and stderr are also set on the error object
        return console.error(`Command failed with error code of #${err.status}`);
    }

    console.log(stdout);
    console.log(stderr);
});

// ...or Promise style
bufferedSpawn('git', ['clone', 'git@github.com/bower/bower'], { cwd: '.' })
.then((output) => {
    console.log(output.stdout);
    console.log(output.stderr);
}, (err) => {
    // Both stdout and stderr are also set on the error object
    console.error(`Command failed with error code of #${err.status}`);
});

The actual child process is available if necessary:

const buffspawn('buffered-spawn');

// Callback style
const cp = buffspawn('git', ['clone', 'git@github.com/bower/bower'], () => {}};

// ...or Promise style
const promise = buffspawn('git', ['clone', 'git@github.com/bower/bower']);
const cp = promise.cp;

As said before, buffered-spawn uses cross-spawn to actually spawn the process. If you are having trouble running Windows such as wmic which has its own arguments parser, you may disable like so:

const cp = buffspawn('wmic', [
    'logicaldisk', 'where', 'DeviceID="Z:"',
    'get' 'freeSpace,size'
], { crossSpawn: false }, () => {}};

Tests

$ npm test

License

Released under the MIT License.

Current Tags

  • 3.3.2                                ...           latest (8 years ago)

21 Versions

  • 3.3.2                                ...           8 years ago
  • 3.3.1                                ...           8 years ago
  • 3.3.0                                ...           8 years ago
  • 3.2.0                                ...           9 years ago
  • 3.1.0                                ...           9 years ago
  • 3.0.0                                ...           9 years ago
  • 2.0.4                                ...           9 years ago
  • 2.0.2                                ...           9 years ago
  • 2.0.1                                ...           9 years ago
  • 2.0.0                                ...           9 years ago
  • 1.1.2                                ...           9 years ago
  • 1.1.1                                ...           9 years ago
  • 1.1.0                                ...           10 years ago
  • 1.0.1                                ...           10 years ago
  • 1.0.0                                ...           10 years ago
  • 0.2.2                                ...           10 years ago
  • 0.2.1                                ...           10 years ago
  • 0.2.0                                ...           10 years ago
  • 0.1.2                                ...           10 years ago
  • 0.1.1                                ...           10 years ago
  • 0.1.0                                ...           10 years ago
Downloads
Total 15
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE