{"_id":"spawn-error-forwarder","_rev":"221808","name":"spawn-error-forwarder","description":"Emit errors on stdout stream for a spawned child process","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"bendrucker","email":"bvdrucker@gmail.com"}],"time":{"modified":"2021-06-03T15:40:24.000Z","created":"2014-11-23T20:19:26.090Z","1.0.0":"2014-11-23T20:19:26.090Z"},"users":{},"author":{"name":"Ben Drucker","email":"bvdrucker@gmail.com","url":"http://bendrucker.me"},"repository":{"type":"git","url":"https://github.com/bendrucker/spawn-error-forwarder.git"},"versions":{"1.0.0":{"name":"spawn-error-forwarder","version":"1.0.0","description":"Emit errors on stdout stream for a spawned child process","main":"./src","directories":{"test":"test"},"scripts":{"test":"mocha"},"repository":{"type":"git","url":"https://github.com/bendrucker/spawn-error-forwarder.git"},"keywords":["child_processs","spawn","error","stdout","stderr"],"author":{"name":"Ben Drucker","email":"bvdrucker@gmail.com","url":"http://bendrucker.me"},"license":"MIT","bugs":{"url":"https://github.com/bendrucker/spawn-error-forwarder/issues"},"homepage":"https://github.com/bendrucker/spawn-error-forwarder","devDependencies":{"chai":"~1.10.0"},"gitHead":"db7cdc7123497ad0ca20590efe50f38d16c75191","_id":"spawn-error-forwarder@1.0.0","_shasum":"1afd94738e999b0346d7b9fc373be55e07577029","_from":".","_npmVersion":"2.1.7","_nodeVersion":"0.10.33","_npmUser":{"name":"bendrucker","email":"bvdrucker@gmail.com"},"maintainers":[{"name":"bendrucker","email":"bvdrucker@gmail.com"}],"dist":{"shasum":"1afd94738e999b0346d7b9fc373be55e07577029","size":1990,"noattachment":false,"key":"/spawn-error-forwarder/-/spawn-error-forwarder-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/spawn-error-forwarder/download/spawn-error-forwarder-1.0.0.tgz"},"publish_time":1416773966090,"_cnpm_publish_time":1416773966090,"_hasShrinkwrap":false}},"readme":"spawn-error-forwarder [![Build Status](https://travis-ci.org/bendrucker/spawn-error-forwarder.svg?branch=master)](https://travis-ci.org/bendrucker/spawn-error-forwarder)\n=====================\n\nEmit errors on stdout stream for a spawned child process. Useful for capturing errors from a spawned process when you want the output from stdout. \n\n## Setup\n```bash\n$ npm install spawn-error-forwarder\n```\n\n## API\n\n#### `fwd(child [, errFactory]` -> `child`\n\nBuffers `child.stderr` output. If the spawned process exits with a code `> 0`, the buffered output of `child.stderr` is used to generate an error which is emitted on `child.stdout`. By default, the error message is the output of `child.stderr`. If you provide an `errFactory` function, it will be called with `code, stderr` where `code` is the child's exit code and `stderr` is string that contains the output of `child.stderr`. `errFactory` should return an `Error` to be emitted on `child.stdout`. \n\n## Example\n\n```js\nvar fwd   = require('spawn-error-forwarder');\nvar spawn = require('child_process').spawn;\nvar child = spawn('git', ['log', 'non-existent-path']);\n\nfwd(child, function (code, stderr) {\n  return new Error('git log exited with ' + code + ':\\n\\n' + stderr);\n});\n\nchild.stdout\n  .on('error', console.error.bind(console))\n  .pipe(process.stdout);\n```\n\nWe want to pipe the output of `git log` to `process.stdout` but since we're providing a path that doesn't exist git will exit with a non-zero code and we'll log its output with `console.error`. \n","_attachments":{},"homepage":"https://github.com/bendrucker/spawn-error-forwarder","bugs":{"url":"https://github.com/bendrucker/spawn-error-forwarder/issues"},"license":"MIT"}