index.js 451 B

12345678910111213141516171819202122
  1. 'use strict';
  2. const path = require('path');
  3. const globalDirs = require('global-dirs');
  4. const resolveGlobal = moduleId => {
  5. try {
  6. return require.resolve(path.join(globalDirs.yarn.packages, moduleId));
  7. } catch (_) {
  8. return require.resolve(path.join(globalDirs.npm.packages, moduleId));
  9. }
  10. };
  11. module.exports = resolveGlobal;
  12. module.exports.silent = moduleId => {
  13. try {
  14. return resolveGlobal(moduleId);
  15. } catch (_) {
  16. return undefined;
  17. }
  18. };