Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
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.

README.md 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. # exit-on-epipe
  2. Cleanly exit on pipe errors in NodeJS scripts.
  3. NOTE: The underlying problem was addressed in 8.x NodeJS versions but the fix
  4. was not backported to 6.x and other versions of NodeJS.
  5. These errors are common in pipelines that involve NodeJS scripts. For example,
  6. take a simple script that prints out 10 lines:
  7. ```js
  8. for(var i = 0; i < 10; ++i) console.log(i)
  9. ```
  10. NodeJS will print an error message if the output is truncated:
  11. ```bash
  12. $ cat t.js
  13. for(var i = 0; i < 10; ++i) console.log(i)
  14. $ node --version
  15. v6.11.1
  16. $ node t.js | head -n 1
  17. 0
  18. events.js:160
  19. throw er; // Unhandled 'error' event
  20. ^
  21. Error: write EPIPE
  22. at exports._errnoException (util.js:1018:11)
  23. at WriteWrap.afterWrite (net.js:800:14)
  24. ```
  25. The process will cleanly exit if you require the module:
  26. ```bash
  27. $ cat t.js
  28. require("exit-on-epipe");
  29. for(var i = 0; i < 10; ++i) console.log(i)
  30. $ node t.js | head -n 1
  31. 0
  32. ```
  33. ## Installation
  34. With [npm](https://www.npmjs.org/package/exit-on-epipe):
  35. ```bash
  36. $ npm install exit-on-epipe
  37. ```
  38. ## Usage
  39. For basic scripts, requiring at the top of the source file suffices:
  40. ```js
  41. require('exit-on-epipe');
  42. // ... rest of source
  43. ```
  44. For more advanced situations (e.g. handing other streams), call the module:
  45. ```js
  46. var eoepipe = require('exit-on-epipe');
  47. eoepipe(stream); // will exit process on an EPIPE error on stream
  48. eoepipe(stream, handler); // will call handler() instead of process.exit
  49. ```
  50. ## Interface
  51. The module exports a single function (exposed as the variable `eoepipe`).
  52. `eoepipe(stream, bail)` will attach an error handler to `stream` which will:
  53. - call the `bail` function if the error `.code` is `"EPIPE"` or `.errno` is `32`
  54. - defer to the default behavior if there are no other error handlers
  55. - noop if the error is not `EPIPE` and if there are other error handlers
  56. If the `bail` function is not specified, `process.exit` is used.
  57. If the `stream` parameter is not specified, no action will be taken
  58. ## Notes
  59. The script will not perform any action if `process` or `process.stdout` are not
  60. available. It is safe to use in a web page.
  61. ## License
  62. Please consult the attached LICENSE file for details. All rights not explicitly
  63. granted by the Apache 2.0 license are reserved by the Original Author.
  64. ## Badges
  65. [![Build Status](https://travis-ci.org/SheetJS/node-exit-on-epipe.svg?branch=master)](https://travis-ci.org/SheetJS/node-exit-on-epipe)
  66. [![npm license](https://img.shields.io/npm/l/exit-on-epipe.svg)](https://npmjs.org/package/exit-on-epipe)
  67. [![NPM Downloads](https://img.shields.io/npm/dt/exit-on-epipe.svg)](https://npmjs.org/package/exit-on-epipe)
  68. [![Dependencies Status](https://david-dm.org/sheetjs/node-exit-on-epipe/status.svg)](https://david-dm.org/sheetjs/node-exit-on-epipe)
  69. [![ghit.me](https://ghit.me/badge.svg?repo=sheetjs/node-exit-on-epipe)](https://ghit.me/repo/sheetjs/node-exit-on-epipe)
  70. [![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/node-exit-on-epipe?pixel)](https://github.com/SheetJS/node-exit-on-epipe)