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.

getModulePath.js 777B

12345678910111213141516171819202122232425262728293031
  1. 'use strict';
  2. const configurationError = require('./configurationError');
  3. const globalModules = require('global-modules');
  4. const resolveFrom = require('resolve-from');
  5. /**
  6. * @param {string} basedir
  7. * @param {string} lookup
  8. * @return {string}
  9. */
  10. module.exports = function getModulePath(basedir, lookup) {
  11. // 1. Try to resolve from the provided directory
  12. // 2. Try to resolve from `process.cwd`
  13. // 3. Try to resolve from global `node_modules` directory
  14. let path = resolveFrom.silent(basedir, lookup);
  15. if (!path) {
  16. path = resolveFrom.silent(process.cwd(), lookup);
  17. }
  18. if (!path) {
  19. path = resolveFrom.silent(globalModules, lookup);
  20. }
  21. if (!path) {
  22. throw configurationError(`Could not find "${lookup}". Do you need a \`configBasedir\`?`);
  23. }
  24. return path;
  25. };