Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

buffered-spawn

Package Overview
Dependencies
Maintainers
5
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

buffered-spawn

Buffered child process#spawn.

  • 1.1.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
5
Created
Source

buffered-spawn Build Status

Buffered child_process#spawn.

Installation

$ npm install buffered-spawn

Why

  • Easy to use
  • Uses cross-spawn that fixes windows issues
  • Supports callback & promise style

Usage

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

var buffspawn = require('buffered-spawn');

// Callback style
buffspawn('git', ['clone', 'git@github.com/bower/bower'], { cwd: '~/foo' }, function (err, stdout, stderr) {
    // Both stdout and stderr are set with the buffered output, even on failure
    if (err) {
        return console.err('Command failed with error code of #'  + err.status);
    }

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

// Promise style
buffspawn('git', ['clone', 'git@github.com/bower/bower'], { cwd: '~/foo' })
.spread(function (stdout, stderr) {
    console.log(stdout);
    console.log(stderr);
}, function (err) {
    // Besides err.status there's also err.stdout & err.stderr
    console.err('Command failed with error code of #'  + err.status);
});

When using promises you can also get feedback via progress:

buffspawn('git', ['clone', 'git@github.com/bower/bower'])
.progress(function (buff) {
    console.log(buff.toString());
})
.spread(function (stdout, stderr) {
    console.log('---------------------------');
    console.log(stdout);
    console.log(stderr);
}, function (err) {
    console.err('Command failed with error code of #'  + err.status);
});

The actual child process is available if necessary:

var buffspawn('buffered-spawn');

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

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

Tests

$ npm test

License

Released under the MIT License.

Keywords

FAQs

Package last updated on 11 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc