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.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. 'use strict';
  2. const isWindows = require("is-windows")
  3. const path = require("path")
  4. const homedir = require("../homedir")
  5. const pathRe = isWindows() ? /^PATH=/i : /^PATH=/;
  6. /**
  7. * Updates the environment variables to intercept `node` commands and pass down options.
  8. *
  9. * @param workingDir {string} Absolute system-dependent path to the directory containing the shim files.
  10. * @param options {import("../munge").InternalSpawnOptions} Original internal spawn options.
  11. * @return {import("../munge").InternalSpawnOptions} Updated internal spawn options.
  12. */
  13. function mungeEnv(workingDir, options) {
  14. let pathEnv
  15. const envPairs = options.envPairs.map((ep) => {
  16. if (pathRe.test(ep)) {
  17. // `PATH` env var: prefix its value with `workingDir`
  18. // `5` corresponds to the length of `PATH=`
  19. pathEnv = ep.substr(5)
  20. const k = ep.substr(0, 5)
  21. return k + workingDir + path.delimiter + pathEnv
  22. } else {
  23. // Return as-is
  24. return ep;
  25. }
  26. });
  27. if (pathEnv === undefined) {
  28. envPairs.push((isWindows() ? 'Path=' : 'PATH=') + workingDir)
  29. }
  30. if (options.originalNode) {
  31. const key = path.basename(workingDir).substr('.node-spawn-wrap-'.length)
  32. envPairs.push('SW_ORIG_' + key + '=' + options.originalNode)
  33. }
  34. envPairs.push('SPAWN_WRAP_SHIM_ROOT=' + homedir)
  35. if (process.env.SPAWN_WRAP_DEBUG === '1') {
  36. envPairs.push('SPAWN_WRAP_DEBUG=1')
  37. }
  38. return {...options, envPairs};
  39. }
  40. module.exports = mungeEnv