Simple email application for Android. Original source code: https://framagit.org/dystopia-project/simple-email
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.5 KiB

  1. spawn-error-forwarder [![Build Status](https://travis-ci.org/bendrucker/spawn-error-forwarder.svg?branch=master)](https://travis-ci.org/bendrucker/spawn-error-forwarder)
  2. =====================
  3. Emit errors on stdout stream for a spawned child process. Useful for capturing errors from a spawned process when you want the output from stdout.
  4. ## Setup
  5. ```bash
  6. $ npm install spawn-error-forwarder
  7. ```
  8. ## API
  9. #### `fwd(child [, errFactory]` -> `child`
  10. Buffers `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`.
  11. ## Example
  12. ```js
  13. var fwd = require('spawn-error-forwarder');
  14. var spawn = require('child_process').spawn;
  15. var child = spawn('git', ['log', 'non-existent-path']);
  16. fwd(child, function (code, stderr) {
  17. return new Error('git log exited with ' + code + ':\n\n' + stderr);
  18. });
  19. child.stdout
  20. .on('error', console.error.bind(console))
  21. .pipe(process.stdout);
  22. ```
  23. We 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`.