2022-11-10 11:43:16 +01:00
|
|
|
'use strict';
|
|
|
|
exports.__esModule = true;
|
2020-08-26 01:57:08 +02:00
|
|
|
|
2022-11-10 11:43:16 +01:00
|
|
|
const Module = require('module');
|
|
|
|
const path = require('path');
|
2020-08-26 01:57:08 +02:00
|
|
|
|
|
|
|
// borrowed from babel-eslint
|
|
|
|
function createModule(filename) {
|
2022-11-10 11:43:16 +01:00
|
|
|
const mod = new Module(filename);
|
|
|
|
mod.filename = filename;
|
|
|
|
mod.paths = Module._nodeModulePaths(path.dirname(filename));
|
|
|
|
return mod;
|
2020-08-26 01:57:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
exports.default = function moduleRequire(p) {
|
|
|
|
try {
|
|
|
|
// attempt to get espree relative to eslint
|
2022-11-10 11:43:16 +01:00
|
|
|
const eslintPath = require.resolve('eslint');
|
|
|
|
const eslintModule = createModule(eslintPath);
|
|
|
|
return require(Module._resolveFilename(p, eslintModule));
|
|
|
|
} catch (err) { /* ignore */ }
|
2020-08-26 01:57:08 +02:00
|
|
|
|
|
|
|
try {
|
|
|
|
// try relative to entry point
|
2022-11-10 11:43:16 +01:00
|
|
|
return require.main.require(p);
|
|
|
|
} catch (err) { /* ignore */ }
|
2020-08-26 01:57:08 +02:00
|
|
|
|
|
|
|
// finally, try from here
|
2022-11-10 11:43:16 +01:00
|
|
|
return require(p);
|
|
|
|
};
|