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.

16 lines
425 B

4 years ago
  1. 'use strict';
  2. var inspect = require('util').inspect;
  3. module.exports = function isResolvable(moduleId, options) {
  4. if (typeof moduleId !== 'string') {
  5. throw new TypeError(inspect(moduleId) + ' is not a string. Expected a valid Node.js module identifier (<string>), for example \'eslint\', \'./index.js\', \'./lib\'.');
  6. }
  7. try {
  8. require.resolve(moduleId, options);
  9. return true;
  10. } catch (err) {
  11. return false;
  12. }
  13. };