1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 8x 6x 6x 3x | import path from 'path';
export default (relativeTo, paths) => {
let result;
for (const testPath of paths.concat(paths.map(mapPath => path.resolve(relativeTo, mapPath)))) {
try {
result = require(testPath);
return typeof result === 'object' && result && result.default ? result.default : result;
} catch (err) {
// Ignore the error
}
}
};
|