Socket
Socket
Sign inDemoInstall

capture-spawn

Package Overview
Dependencies
6
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    capture-spawn

Asynchronously capturing spawn output.


Version published
Maintainers
1
Install size
50.6 kB
Created

Changelog

Source

1.0.1 - 2016-03-20

  • Release v1.0.1 / npm@v1.0.1
  • add keywords

Readme

Source

capture-spawn npmjs.com The MIT License

Asynchronously capturing spawn output.

code climate standard code style travis build status coverage status dependency status

Install

npm i capture-spawn --save

Usage

For more use-cases see the tests

const captureSpawn = require('capture-spawn')

captureSpawn

Capture output of asynchronous spawn.

Params

  • cp {Stream}: Child process spawn stream.
  • callback {Function}: Gets error, result or result buffer - cb(err, res, buf).
  • returns {Stream}: Passed cp stream.

Example

var captureSpawn = require('capture-spawn')
var spawn = require('cross-spawn-async')

var cp = spawn('echo', ['hello charlike', 'world'])
var stream = captureSpawn(cp, function callback (err, res, buf) {
  if (err) return console.error(err)
  console.log('result', res) // => 'hello charlike world\n'
  console.log('buffer', buf) // => <Buffer ...>
  console.log('result === buffer.toString()', buf.toString()) // => 'hello charlike world\n'
})
console.log(cp === stream) // => true

Error handling

Where buffer is the stderr output and code can be string or number.

var proc = spawn('node', ['not-exist', 'something'])
captureSpawn(proc, console.log)
// => SpawnError {
//   name: 'SpawnError',
//   message: '',
//   code: 1,
//   buffer: <Buffer 6d 6f 64 75 ...>
// }

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.

Charlike Make Reagent new message to charlike freenode #charlike

tunnckoCore.tk keybase tunnckoCore tunnckoCore npm tunnckoCore twitter tunnckoCore github

Keywords

FAQs

Last updated on 20 Mar 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc