mirror of https://github.com/lukechilds/node.git
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.
26 lines
467 B
26 lines
467 B
'use strict';
|
|
|
|
var tryit = require('tryit');
|
|
|
|
module.exports = function isResolvable(moduleId) {
|
|
if (typeof moduleId !== 'string') {
|
|
throw new TypeError(
|
|
moduleId +
|
|
' is not a string. A module identifier to be checked if resolvable is required.'
|
|
);
|
|
}
|
|
|
|
var result;
|
|
tryit(function() {
|
|
require.resolve(moduleId);
|
|
}, function(err) {
|
|
if (err) {
|
|
result = false;
|
|
return;
|
|
}
|
|
|
|
result = true;
|
|
});
|
|
|
|
return result;
|
|
};
|
|
|