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

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * Utility for resolving a module relative to another module
  3. * @author Teddy Katz
  4. */
  5. "use strict";
  6. const Module = require("module");
  7. /*
  8. * `Module.createRequire` is added in v12.2.0. It supports URL as well.
  9. * We only support the case where the argument is a filepath, not a URL.
  10. */
  11. // eslint-disable-next-line node/no-unsupported-features/node-builtins, node/no-deprecated-api
  12. const createRequire = Module.createRequire || Module.createRequireFromPath;
  13. module.exports = {
  14. /**
  15. * Resolves a Node module relative to another module
  16. * @param {string} moduleName The name of a Node module, or a path to a Node module.
  17. * @param {string} relativeToPath An absolute path indicating the module that `moduleName` should be resolved relative to. This must be
  18. * a file rather than a directory, but the file need not actually exist.
  19. * @returns {string} The absolute path that would result from calling `require.resolve(moduleName)` in a file located at `relativeToPath`
  20. */
  21. resolve(moduleName, relativeToPath) {
  22. try {
  23. return createRequire(relativeToPath).resolve(moduleName);
  24. } catch (error) {
  25. // This `if` block is for older Node.js than 12.0.0. We can remove this block in the future.
  26. if (
  27. typeof error === "object" &&
  28. error !== null &&
  29. error.code === "MODULE_NOT_FOUND" &&
  30. !error.requireStack &&
  31. error.message.includes(moduleName)
  32. ) {
  33. error.message += `\nRequire stack:\n- ${relativeToPath}`;
  34. }
  35. throw error;
  36. }
  37. }
  38. };