????JFIF??x?x????'
| Server IP : 79.136.114.73 / Your IP : 216.73.216.217 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/appsrv.astacus.se/forge/node_modules/eslint/lib/util/ |
Upload File : |
/**
* @fileoverview Implements the Node.js require.resolve algorithm
* @author Nicholas C. Zakas
*/
"use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const Module = require("module");
//------------------------------------------------------------------------------
// Private
//------------------------------------------------------------------------------
const DEFAULT_OPTIONS = {
/*
* module.paths is an array of paths to search for resolving things relative
* to this file. Module.globalPaths contains all of the special Node.js
* directories that can also be searched for modules.
*
* Need to check for existence of module.paths because Jest seems not to
* include it. See https://github.com/eslint/eslint/issues/5791.
*/
lookupPaths: module.paths ? module.paths.concat(Module.globalPaths) : Module.globalPaths.concat()
};
/**
* Resolves modules based on a set of options.
*/
class ModuleResolver {
/**
* Resolves modules based on a set of options.
* @param {Object} options The options for resolving modules.
* @param {string[]} options.lookupPaths An array of paths to include in the
* lookup with the highest priority paths coming first.
*/
constructor(options) {
this.options = Object.assign({}, DEFAULT_OPTIONS, options || {});
}
/**
* Resolves the file location of a given module relative to the configured
* lookup paths.
* @param {string} name The module name to resolve.
* @param {string} extraLookupPath An extra path to look into for the module.
* This path is used with the highest priority.
* @returns {string} The resolved file path for the module.
* @throws {Error} If the module cannot be resolved.
*/
resolve(name, extraLookupPath) {
/*
* First, clone the lookup paths so we're not messing things up for
* subsequent calls to this function. Then, move the extraLookupPath to the
* top of the lookup paths list so it will be searched first.
*/
const lookupPaths = [extraLookupPath, ...this.options.lookupPaths];
/**
* Module._findPath is an internal method to Node.js, then one they use to
* lookup file paths when require() is called. So, we are hooking into the
* exact same logic that Node.js uses.
*/
const result = Module._findPath(name, lookupPaths); // eslint-disable-line no-underscore-dangle
if (!result) {
throw new Error(`Cannot find module '${name}'`);
}
return result;
}
}
//------------------------------------------------------------------------------
// Public API
//------------------------------------------------------------------------------
module.exports = ModuleResolver;