parcoursup/node_modules/rechoir/lib/register.js
lalBi94 7bc56c09b5 $
2023-03-05 13:23:23 +01:00

16 lines
339 B
JavaScript

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;
};