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.

relative-module-resolver.js 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * STOP!!! DO NOT MODIFY.
  3. *
  4. * This file is part of the ongoing work to move the eslintrc-style config
  5. * system into the @eslint/eslintrc package. This file needs to remain
  6. * unchanged in order for this work to proceed.
  7. *
  8. * If you think you need to change this file, please contact @nzakas first.
  9. *
  10. * Thanks in advance for your cooperation.
  11. */
  12. /**
  13. * Utility for resolving a module relative to another module
  14. * @author Teddy Katz
  15. */
  16. "use strict";
  17. const Module = require("module");
  18. /*
  19. * `Module.createRequire` is added in v12.2.0. It supports URL as well.
  20. * We only support the case where the argument is a filepath, not a URL.
  21. */
  22. // eslint-disable-next-line node/no-unsupported-features/node-builtins, node/no-deprecated-api
  23. const createRequire = Module.createRequire || Module.createRequireFromPath;
  24. module.exports = {
  25. /**
  26. * Resolves a Node module relative to another module
  27. * @param {string} moduleName The name of a Node module, or a path to a Node module.
  28. * @param {string} relativeToPath An absolute path indicating the module that `moduleName` should be resolved relative to. This must be
  29. * a file rather than a directory, but the file need not actually exist.
  30. * @returns {string} The absolute path that would result from calling `require.resolve(moduleName)` in a file located at `relativeToPath`
  31. */
  32. resolve(moduleName, relativeToPath) {
  33. try {
  34. return createRequire(relativeToPath).resolve(moduleName);
  35. } catch (error) {
  36. // This `if` block is for older Node.js than 12.0.0. We can remove this block in the future.
  37. if (
  38. typeof error === "object" &&
  39. error !== null &&
  40. error.code === "MODULE_NOT_FOUND" &&
  41. !error.requireStack &&
  42. error.message.includes(moduleName)
  43. ) {
  44. error.message += `\nRequire stack:\n- ${relativeToPath}`;
  45. }
  46. throw error;
  47. }
  48. }
  49. };