index.js 397 B

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