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 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. # spawn-wrap
  2. Wrap all spawned Node.js child processes by adding environs and
  3. arguments ahead of the main JavaScript file argument.
  4. Any child processes launched by that child process will also be
  5. wrapped in a similar fashion.
  6. This is a bit of a brutal hack, designed primarily to support code
  7. coverage reporting in cases where tests or the system under test are
  8. loaded via child processes rather than via `require()`.
  9. It can also be handy if you want to run your own mock executable
  10. instead of some other thing when child procs call into it.
  11. [![Build Status](https://travis-ci.org/istanbuljs/spawn-wrap.svg)](https://travis-ci.org/istanbuljs/spawn-wrap)
  12. ## USAGE
  13. ```javascript
  14. var wrap = require('spawn-wrap')
  15. // wrap(wrapperArgs, environs)
  16. var unwrap = wrap(['/path/to/my/main.js', 'foo=bar'], { FOO: 1 })
  17. // later to undo the wrapping, you can call the returned function
  18. unwrap()
  19. ```
  20. In this example, the `/path/to/my/main.js` file will be used as the
  21. "main" module, whenever any Node or io.js child process is started,
  22. whether via a call to `spawn` or `exec`, whether node is invoked
  23. directly as the command or as the result of a shebang `#!` lookup.
  24. In `/path/to/my/main.js`, you can do whatever instrumentation or
  25. environment manipulation you like. When you're done, and ready to run
  26. the "real" main.js file (ie, the one that was spawned in the first
  27. place), you can do this:
  28. ```javascript
  29. // /path/to/my/main.js
  30. // process.argv[1] === 'foo=bar'
  31. // and process.env.FOO === '1'
  32. // my wrapping manipulations
  33. setupInstrumentationOrCoverageOrWhatever()
  34. process.on('exit', function (code) {
  35. storeCoverageInfoSynchronously()
  36. })
  37. // now run the instrumented and covered or whatever codes
  38. require('spawn-wrap').runMain()
  39. ```
  40. ## ENVIRONMENT VARIABLES
  41. Spawn-wrap responds to two environment variables, both of which are
  42. preserved through child processes.
  43. `SPAWN_WRAP_DEBUG=1` in the environment will make this module dump a
  44. lot of information to stderr.
  45. `SPAWN_WRAP_SHIM_ROOT` can be set to a path on the filesystem where
  46. the shim files are written in a `.node-spawn-wrap-<id>` folder. By
  47. default this is done in `$HOME`, but in some environments you may wish
  48. to point it at some other root. (For example, if `$HOME` is mounted
  49. as read-only in a virtual machine or container.)
  50. ## CONTRACTS and CAVEATS
  51. The initial wrap call uses synchronous I/O. Probably you should not
  52. be using this script in any production environments anyway.
  53. Also, this will slow down child process execution by a lot, since
  54. we're adding a few layers of indirection.
  55. The contract which this library aims to uphold is:
  56. * Wrapped processes behave identical to their unwrapped counterparts
  57. for all intents and purposes. That means that the wrapper script
  58. propagates all signals and exit codes.
  59. * If you send a signal to the wrapper, the child gets the signal.
  60. * If the child exits with a numeric status code, then the wrapper
  61. exits with that code.
  62. * If the child dies with a signal, then the wrapper dies with the
  63. same signal.
  64. * If you execute any Node child process, in any of the various ways
  65. that such a thing can be done, it will be wrapped.
  66. * Children of wrapped processes are also wrapped.
  67. (Much of this made possible by
  68. [foreground-child](http://npm.im/foreground-child).)
  69. There are a few ways situations in which this contract cannot be
  70. adhered to, despite best efforts:
  71. 1. In order to handle cases where `node` is invoked in a shell script,
  72. the `PATH` environment variable is modified such that the the shim
  73. will be run before the "real" node. However, since Windows does
  74. not allow executing shebang scripts like regular programs, a
  75. `node.cmd` file is required.
  76. 2. Signal propagation through `dash` doesn't always work. So, if you
  77. use `child_process.exec()` on systems where `/bin/sh` is actually
  78. `dash`, then the process may exit with a status code > 128 rather
  79. than indicating that it received a signal.
  80. 3. `cmd.exe` is even stranger with how it propagates and interprets
  81. unix signals. If you want your programs to be portable, then
  82. probably you wanna not rely on signals too much.
  83. 4. It *is* possible to escape the wrapping, if you spawn a bash
  84. script, and that script modifies the `PATH`, and then calls a
  85. specific `node` binary explicitly.