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.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. 'use strict';
  2. const isWindows = require("is-windows")
  3. const path = require("path")
  4. const {debug} = require("../debug")
  5. const {isNode} = require("../exe-type")
  6. const whichOrUndefined = require("../which-or-undefined")
  7. /**
  8. * Intercepts Node and npm processes spawned through a Linux shell.
  9. *
  10. * @param workingDir {string} Absolute system-dependent path to the directory containing the shim files.
  11. * @param options {import("../munge").InternalSpawnOptions} Original internal spawn options.
  12. * @return {import("../munge").InternalSpawnOptions} Updated internal spawn options.
  13. */
  14. function mungeSh(workingDir, options) {
  15. const cmdi = options.args.indexOf('-c')
  16. if (cmdi === -1) {
  17. return {...options} // no -c argument
  18. }
  19. let c = options.args[cmdi + 1]
  20. const re = /^\s*((?:[^\= ]*\=[^\=\s]*)*[\s]*)([^\s]+|"[^"]+"|'[^']+')( .*)?$/
  21. const match = c.match(re)
  22. if (match === null) {
  23. return {...options} // not a command invocation. weird but possible
  24. }
  25. let command = match[2]
  26. // strip quotes off the command
  27. const quote = command.charAt(0)
  28. if ((quote === '"' || quote === '\'') && command.endsWith(quote)) {
  29. command = command.slice(1, -1)
  30. }
  31. const exe = path.basename(command)
  32. let newArgs = [...options.args];
  33. // Remember the original Node command to use it in the shim
  34. let originalNode;
  35. const workingNode = path.join(workingDir, 'node')
  36. if (isNode(exe)) {
  37. originalNode = command
  38. c = `${match[1]}${match[2]} "${workingNode}" ${match[3]}`
  39. newArgs[cmdi + 1] = c
  40. } else if (exe === 'npm' && !isWindows()) {
  41. // XXX this will exhibit weird behavior when using /path/to/npm,
  42. // if some other npm is first in the path.
  43. const npmPath = whichOrUndefined('npm')
  44. if (npmPath) {
  45. c = c.replace(re, `$1 "${workingNode}" "${npmPath}" $3`)
  46. newArgs[cmdi + 1] = c
  47. debug('npm munge!', c)
  48. }
  49. }
  50. return {...options, args: newArgs, originalNode};
  51. }
  52. module.exports = mungeSh