Permalink
Cannot retrieve contributors at this time
31 lines (25 sloc)
779 Bytes
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/eslint-module-utils/module-require.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
exports.__esModule = true; | |
const Module = require('module'); | |
const path = require('path'); | |
// borrowed from babel-eslint | |
function createModule(filename) { | |
const mod = new Module(filename); | |
mod.filename = filename; | |
mod.paths = Module._nodeModulePaths(path.dirname(filename)); | |
return mod; | |
} | |
exports.default = function moduleRequire(p) { | |
try { | |
// attempt to get espree relative to eslint | |
const eslintPath = require.resolve('eslint'); | |
const eslintModule = createModule(eslintPath); | |
return require(Module._resolveFilename(p, eslintModule)); | |
} catch (err) { /* ignore */ } | |
try { | |
// try relative to entry point | |
return require.main.require(p); | |
} catch (err) { /* ignore */ } | |
// finally, try from here | |
return require(p); | |
}; |