parcoursup/node_modules/rechoir/lib/register.js

16 lines
339 B
JavaScript
Raw Normal View History

2023-03-05 13:23:23 +01:00
var resolve = require('resolve');
module.exports = function(cwd, moduleName, register) {
var result;
try {
var modulePath = resolve.sync(moduleName, { basedir: cwd });
result = require(modulePath);
if (typeof register === 'function') {
register(result);
}
} catch (e) {
result = e;
}
return result;
};