This commit is contained in:
eric sciple 2020-01-24 12:22:34 -05:00
parent 9fff29ba6c
commit 00c3b50fca
7278 changed files with 0 additions and 1778943 deletions

23
node_modules/jest-resolve/LICENSE generated vendored
View file

@ -1,23 +0,0 @@
MIT License
For Jest software
Copyright (c) 2014-present, Facebook, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -1,19 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { Config } from '@jest/types';
declare type ResolverOptions = {
basedir: Config.Path;
browser?: boolean;
defaultResolver: typeof defaultResolver;
extensions?: Array<string>;
moduleDirectory?: Array<string>;
paths?: Array<Config.Path>;
rootDir?: Config.Path;
};
export default function defaultResolver(path: Config.Path, options: ResolverOptions): Config.Path;
export {};
//# sourceMappingURL=defaultResolver.d.ts.map

View file

@ -1 +0,0 @@
{"version":3,"file":"defaultResolver.d.ts","sourceRoot":"","sources":["../src/defaultResolver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAInC,aAAK,eAAe,GAAG;IACrB,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,OAAO,eAAe,CAAC;IACxC,UAAU,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3B,eAAe,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAChC,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC;CACvB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,IAAI,EAAE,MAAM,CAAC,IAAI,EACjB,OAAO,EAAE,eAAe,GACvB,MAAM,CAAC,IAAI,CAgBb"}

View file

@ -1,247 +0,0 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = defaultResolver;
function _fs() {
const data = _interopRequireDefault(require('fs'));
_fs = function _fs() {
return data;
};
return data;
}
function _path() {
const data = _interopRequireDefault(require('path'));
_path = function _path() {
return data;
};
return data;
}
function _browserResolve() {
const data = _interopRequireDefault(require('browser-resolve'));
_browserResolve = function _browserResolve() {
return data;
};
return data;
}
function _jestPnpResolver() {
const data = _interopRequireDefault(require('jest-pnp-resolver'));
_jestPnpResolver = function _jestPnpResolver() {
return data;
};
return data;
}
var _isBuiltinModule = _interopRequireDefault(require('./isBuiltinModule'));
var _nodeModulesPaths = _interopRequireDefault(require('./nodeModulesPaths'));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
function defaultResolver(path, options) {
// @ts-ignore: the "pnp" version named isn't in DefinitelyTyped
if (process.versions.pnp) {
return (0, _jestPnpResolver().default)(path, options);
}
const resolve = options.browser
? _browserResolve().default.sync
: resolveSync;
return resolve(path, {
basedir: options.basedir,
defaultResolver,
extensions: options.extensions,
moduleDirectory: options.moduleDirectory,
paths: options.paths,
rootDir: options.rootDir
});
}
const REGEX_RELATIVE_IMPORT = /^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[\\\/])/;
function resolveSync(target, options) {
const basedir = options.basedir;
const extensions = options.extensions || ['.js'];
const paths = options.paths || [];
if (REGEX_RELATIVE_IMPORT.test(target)) {
// resolve relative import
const resolveTarget = _path().default.resolve(basedir, target);
const result = tryResolve(resolveTarget);
if (result) {
return result;
}
} else {
// otherwise search for node_modules
const dirs = (0, _nodeModulesPaths.default)(basedir, {
moduleDirectory: options.moduleDirectory,
paths
});
for (let i = 0; i < dirs.length; i++) {
const resolveTarget = _path().default.join(dirs[i], target);
const result = tryResolve(resolveTarget);
if (result) {
return result;
}
}
}
if ((0, _isBuiltinModule.default)(target)) {
return target;
}
const err = new Error(
"Cannot find module '" + target + "' from '" + basedir + "'"
);
err.code = 'MODULE_NOT_FOUND';
throw err;
/*
* contextual helper functions
*/
function tryResolve(name) {
const dir = _path().default.dirname(name);
let result;
if (isDirectory(dir)) {
result = resolveAsFile(name) || resolveAsDirectory(name);
}
if (result) {
// Dereference symlinks to ensure we don't create a separate
// module instance depending on how it was referenced.
result = _fs().default.realpathSync(result);
}
return result;
}
function resolveAsFile(name) {
if (isFile(name)) {
return name;
}
for (let i = 0; i < extensions.length; i++) {
const file = name + extensions[i];
if (isFile(file)) {
return file;
}
}
return undefined;
}
function resolveAsDirectory(name) {
if (!isDirectory(name)) {
return undefined;
}
const pkgfile = _path().default.join(name, 'package.json');
let pkgmain;
try {
const body = _fs().default.readFileSync(pkgfile, 'utf8');
pkgmain = JSON.parse(body).main;
} catch (e) {}
if (pkgmain && !isCurrentDirectory(pkgmain)) {
const resolveTarget = _path().default.resolve(name, pkgmain);
const result = tryResolve(resolveTarget);
if (result) {
return result;
}
}
return resolveAsFile(_path().default.join(name, 'index'));
}
}
var IPathType;
(function(IPathType) {
IPathType[(IPathType['FILE'] = 1)] = 'FILE';
IPathType[(IPathType['DIRECTORY'] = 2)] = 'DIRECTORY';
IPathType[(IPathType['OTHER'] = 3)] = 'OTHER';
})(IPathType || (IPathType = {}));
const checkedPaths = new Map();
function statSyncCached(path) {
const result = checkedPaths.get(path);
if (result !== undefined) {
return result;
}
let stat;
try {
stat = _fs().default.statSync(path);
} catch (e) {
if (!(e && (e.code === 'ENOENT' || e.code === 'ENOTDIR'))) {
throw e;
}
}
if (stat) {
if (stat.isFile() || stat.isFIFO()) {
checkedPaths.set(path, IPathType.FILE);
return IPathType.FILE;
} else if (stat.isDirectory()) {
checkedPaths.set(path, IPathType.DIRECTORY);
return IPathType.DIRECTORY;
}
}
checkedPaths.set(path, IPathType.OTHER);
return IPathType.OTHER;
}
/*
* helper functions
*/
function isFile(file) {
return statSyncCached(file) === IPathType.FILE;
}
function isDirectory(dir) {
return statSyncCached(dir) === IPathType.DIRECTORY;
}
const CURRENT_DIRECTORY = _path().default.resolve('.');
function isCurrentDirectory(testPath) {
return CURRENT_DIRECTORY === _path().default.resolve(testPath);
}

View file

@ -1,54 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { Config } from '@jest/types';
import { ModuleMap } from 'jest-haste-map';
import { ResolverConfig } from './types';
declare type FindNodeModuleConfig = {
basedir: Config.Path;
browser?: boolean;
extensions?: Array<string>;
moduleDirectory?: Array<string>;
paths?: Array<Config.Path>;
resolver?: Config.Path | null;
rootDir?: Config.Path;
};
declare type BooleanObject = {
[key: string]: boolean;
};
declare namespace Resolver {
type ResolveModuleConfig = {
skipNodeResolution?: boolean;
paths?: Array<Config.Path>;
};
}
declare class Resolver {
private readonly _options;
private readonly _moduleMap;
private readonly _moduleIDCache;
private readonly _moduleNameCache;
private readonly _modulePathCache;
private readonly _supportsNativePlatform;
constructor(moduleMap: ModuleMap, options: ResolverConfig);
static findNodeModule(path: Config.Path, options: FindNodeModuleConfig): Config.Path | null;
resolveModuleFromDirIfExists(dirname: Config.Path, moduleName: string, options?: Resolver.ResolveModuleConfig): Config.Path | null;
resolveModule(from: Config.Path, moduleName: string, options?: Resolver.ResolveModuleConfig): Config.Path;
isCoreModule(moduleName: string): boolean;
getModule(name: string): Config.Path | null;
getModulePath(from: Config.Path, moduleName: string): string;
getPackage(name: string): Config.Path | null;
getMockModule(from: Config.Path, name: string): Config.Path | null;
getModulePaths(from: Config.Path): Array<Config.Path>;
getModuleID(virtualMocks: BooleanObject, from: Config.Path, _moduleName?: string): string;
private _getModuleType;
private _getAbsolutePath;
private _getMockPath;
private _getVirtualMockPath;
private _isModuleResolved;
resolveStubModuleName(from: Config.Path, moduleName: string): Config.Path | null;
}
export = Resolver;
//# sourceMappingURL=index.d.ts.map

View file

@ -1 +0,0 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}

View file

@ -1,490 +0,0 @@
'use strict';
function _path() {
const data = _interopRequireDefault(require('path'));
_path = function _path() {
return data;
};
return data;
}
function _realpathNative() {
const data = require('realpath-native');
_realpathNative = function _realpathNative() {
return data;
};
return data;
}
function _chalk() {
const data = _interopRequireDefault(require('chalk'));
_chalk = function _chalk() {
return data;
};
return data;
}
var _nodeModulesPaths = _interopRequireDefault(require('./nodeModulesPaths'));
var _isBuiltinModule = _interopRequireDefault(require('./isBuiltinModule'));
var _defaultResolver = _interopRequireDefault(require('./defaultResolver'));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
const NATIVE_PLATFORM = 'native'; // We might be inside a symlink.
const cwd = process.cwd();
const resolvedCwd = (0, _realpathNative().sync)(cwd) || cwd;
const NODE_PATH = process.env.NODE_PATH;
const nodePaths = NODE_PATH
? NODE_PATH.split(_path().default.delimiter)
.filter(Boolean) // The resolver expects absolute paths.
.map(p => _path().default.resolve(resolvedCwd, p))
: null;
/* eslint-disable-next-line no-redeclare */
class Resolver {
constructor(moduleMap, options) {
_defineProperty(this, '_options', void 0);
_defineProperty(this, '_moduleMap', void 0);
_defineProperty(this, '_moduleIDCache', void 0);
_defineProperty(this, '_moduleNameCache', void 0);
_defineProperty(this, '_modulePathCache', void 0);
_defineProperty(this, '_supportsNativePlatform', void 0);
this._options = {
browser: options.browser,
defaultPlatform: options.defaultPlatform,
extensions: options.extensions,
hasCoreModules:
options.hasCoreModules === undefined ? true : options.hasCoreModules,
moduleDirectories: options.moduleDirectories || ['node_modules'],
moduleNameMapper: options.moduleNameMapper,
modulePaths: options.modulePaths,
platforms: options.platforms,
resolver: options.resolver,
rootDir: options.rootDir
};
this._supportsNativePlatform = options.platforms
? options.platforms.includes(NATIVE_PLATFORM)
: false;
this._moduleMap = moduleMap;
this._moduleIDCache = new Map();
this._moduleNameCache = new Map();
this._modulePathCache = new Map();
}
static findNodeModule(path, options) {
const resolver = options.resolver
? require(options.resolver)
: _defaultResolver.default;
const paths = options.paths;
try {
return resolver(path, {
basedir: options.basedir,
browser: options.browser,
defaultResolver: _defaultResolver.default,
extensions: options.extensions,
moduleDirectory: options.moduleDirectory,
paths: paths ? (nodePaths || []).concat(paths) : nodePaths,
rootDir: options.rootDir
});
} catch (e) {}
return null;
}
resolveModuleFromDirIfExists(dirname, moduleName, options) {
const paths = (options && options.paths) || this._options.modulePaths;
const moduleDirectory = this._options.moduleDirectories;
const key = dirname + _path().default.delimiter + moduleName;
const defaultPlatform = this._options.defaultPlatform;
const extensions = this._options.extensions.slice();
let module;
if (this._supportsNativePlatform) {
extensions.unshift(
...this._options.extensions.map(ext => '.' + NATIVE_PLATFORM + ext)
);
}
if (defaultPlatform) {
extensions.unshift(
...this._options.extensions.map(ext => '.' + defaultPlatform + ext)
);
} // 1. If we have already resolved this module for this directory name,
// return a value from the cache.
const cacheResult = this._moduleNameCache.get(key);
if (cacheResult) {
return cacheResult;
} // 2. Check if the module is a haste module.
module = this.getModule(moduleName);
if (module) {
this._moduleNameCache.set(key, module);
return module;
} // 3. Check if the module is a node module and resolve it based on
// the node module resolution algorithm. If skipNodeResolution is given we
// ignore all modules that look like node modules (ie. are not relative
// requires). This enables us to speed up resolution when we build a
// dependency graph because we don't have to look at modules that may not
// exist and aren't mocked.
const skipResolution =
options &&
options.skipNodeResolution &&
!moduleName.includes(_path().default.sep);
const resolveNodeModule = name =>
Resolver.findNodeModule(name, {
basedir: dirname,
browser: this._options.browser,
extensions,
moduleDirectory,
paths,
resolver: this._options.resolver,
rootDir: this._options.rootDir
});
if (!skipResolution) {
module = resolveNodeModule(moduleName);
if (module) {
this._moduleNameCache.set(key, module);
return module;
}
} // 4. Resolve "haste packages" which are `package.json` files outside of
// `node_modules` folders anywhere in the file system.
const parts = moduleName.split('/');
const hastePackage = this.getPackage(parts.shift());
if (hastePackage) {
try {
const module = _path().default.join.apply(
_path().default,
[_path().default.dirname(hastePackage)].concat(parts)
); // try resolving with custom resolver first to support extensions,
// then fallback to require.resolve
const resolvedModule =
resolveNodeModule(module) || require.resolve(module);
this._moduleNameCache.set(key, resolvedModule);
return resolvedModule;
} catch (ignoredError) {}
}
return null;
}
resolveModule(from, moduleName, options) {
const dirname = _path().default.dirname(from);
const module =
this.resolveStubModuleName(from, moduleName) ||
this.resolveModuleFromDirIfExists(dirname, moduleName, options);
if (module) return module; // 5. Throw an error if the module could not be found. `resolve.sync` only
// produces an error based on the dirname but we have the actual current
// module name available.
const relativePath = _path().default.relative(dirname, from);
const err = new Error(
`Cannot find module '${moduleName}' from '${relativePath || '.'}'`
);
err.code = 'MODULE_NOT_FOUND';
throw err;
}
isCoreModule(moduleName) {
return (
this._options.hasCoreModules && (0, _isBuiltinModule.default)(moduleName)
);
}
getModule(name) {
return this._moduleMap.getModule(
name,
this._options.defaultPlatform,
this._supportsNativePlatform
);
}
getModulePath(from, moduleName) {
if (moduleName[0] !== '.' || _path().default.isAbsolute(moduleName)) {
return moduleName;
}
return _path().default.normalize(
_path().default.dirname(from) + '/' + moduleName
);
}
getPackage(name) {
return this._moduleMap.getPackage(
name,
this._options.defaultPlatform,
this._supportsNativePlatform
);
}
getMockModule(from, name) {
const mock = this._moduleMap.getMockModule(name);
if (mock) {
return mock;
} else {
const moduleName = this.resolveStubModuleName(from, name);
if (moduleName) {
return this.getModule(moduleName) || moduleName;
}
}
return null;
}
getModulePaths(from) {
const cachedModule = this._modulePathCache.get(from);
if (cachedModule) {
return cachedModule;
}
const moduleDirectory = this._options.moduleDirectories;
const paths = (0, _nodeModulesPaths.default)(from, {
moduleDirectory
});
if (paths[paths.length - 1] === undefined) {
// circumvent node-resolve bug that adds `undefined` as last item.
paths.pop();
}
this._modulePathCache.set(from, paths);
return paths;
}
getModuleID(virtualMocks, from, _moduleName) {
const moduleName = _moduleName || '';
const key = from + _path().default.delimiter + moduleName;
const cachedModuleID = this._moduleIDCache.get(key);
if (cachedModuleID) {
return cachedModuleID;
}
const moduleType = this._getModuleType(moduleName);
const absolutePath = this._getAbsolutePath(virtualMocks, from, moduleName);
const mockPath = this._getMockPath(from, moduleName);
const sep = _path().default.delimiter;
const id =
moduleType +
sep +
(absolutePath ? absolutePath + sep : '') +
(mockPath ? mockPath + sep : '');
this._moduleIDCache.set(key, id);
return id;
}
_getModuleType(moduleName) {
return this.isCoreModule(moduleName) ? 'node' : 'user';
}
_getAbsolutePath(virtualMocks, from, moduleName) {
if (this.isCoreModule(moduleName)) {
return moduleName;
}
return this._isModuleResolved(from, moduleName)
? this.getModule(moduleName)
: this._getVirtualMockPath(virtualMocks, from, moduleName);
}
_getMockPath(from, moduleName) {
return !this.isCoreModule(moduleName)
? this.getMockModule(from, moduleName)
: null;
}
_getVirtualMockPath(virtualMocks, from, moduleName) {
const virtualMockPath = this.getModulePath(from, moduleName);
return virtualMocks[virtualMockPath]
? virtualMockPath
: moduleName
? this.resolveModule(from, moduleName)
: from;
}
_isModuleResolved(from, moduleName) {
return !!(
this.getModule(moduleName) || this.getMockModule(from, moduleName)
);
}
resolveStubModuleName(from, moduleName) {
const dirname = _path().default.dirname(from);
const paths = this._options.modulePaths;
const extensions = this._options.extensions.slice();
const moduleDirectory = this._options.moduleDirectories;
const moduleNameMapper = this._options.moduleNameMapper;
const resolver = this._options.resolver;
const defaultPlatform = this._options.defaultPlatform;
if (this._supportsNativePlatform) {
extensions.unshift(
...this._options.extensions.map(ext => '.' + NATIVE_PLATFORM + ext)
);
}
if (defaultPlatform) {
extensions.unshift(
...this._options.extensions.map(ext => '.' + defaultPlatform + ext)
);
}
if (moduleNameMapper) {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (
var _iterator = moduleNameMapper[Symbol.iterator](), _step;
!(_iteratorNormalCompletion = (_step = _iterator.next()).done);
_iteratorNormalCompletion = true
) {
const _step$value = _step.value,
mappedModuleName = _step$value.moduleName,
regex = _step$value.regex;
if (regex.test(moduleName)) {
// Note: once a moduleNameMapper matches the name, it must result
// in a module, or else an error is thrown.
const matches = moduleName.match(regex);
const updatedName = matches
? mappedModuleName.replace(
/\$([0-9]+)/g,
(_, index) => matches[parseInt(index, 10)]
)
: mappedModuleName;
const module =
this.getModule(updatedName) ||
Resolver.findNodeModule(updatedName, {
basedir: dirname,
browser: this._options.browser,
extensions,
moduleDirectory,
paths,
resolver,
rootDir: this._options.rootDir
});
if (!module) {
throw createNoMappedModuleFoundError(
moduleName,
updatedName,
mappedModuleName,
regex,
resolver
);
}
return module;
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
return null;
}
}
const createNoMappedModuleFoundError = (
moduleName,
updatedName,
mappedModuleName,
regex,
resolver
) => {
const error = new Error(
_chalk().default.red(`${_chalk().default.bold('Configuration error')}:
Could not locate module ${_chalk().default.bold(moduleName)} mapped as:
${_chalk().default.bold(updatedName)}.
Please check your configuration for these entries:
{
"moduleNameMapper": {
"${regex.toString()}": "${_chalk().default.bold(mappedModuleName)}"
},
"resolver": ${_chalk().default.bold(String(resolver))}
}`)
);
error.name = '';
return error;
};
module.exports = Resolver;

View file

@ -1,8 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
export default function isBuiltinModule(module: string): boolean;
//# sourceMappingURL=isBuiltinModule.d.ts.map

View file

@ -1 +0,0 @@
{"version":3,"file":"isBuiltinModule.d.ts","sourceRoot":"","sources":["../src/isBuiltinModule.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAmBH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE/D"}

View file

@ -1,39 +0,0 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = isBuiltinModule;
function _module2() {
const data = _interopRequireDefault(require('module'));
_module2 = function _module2() {
return data;
};
return data;
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
const EXPERIMENTAL_MODULES = ['worker_threads'];
const BUILTIN_MODULES = new Set(
_module2().default.builtinModules
? _module2().default.builtinModules.concat(EXPERIMENTAL_MODULES)
: Object.keys(process.binding('natives'))
.filter(module => !/^internal\//.test(module))
.concat(EXPERIMENTAL_MODULES)
);
function isBuiltinModule(module) {
return BUILTIN_MODULES.has(module);
}

View file

@ -1,16 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* Adapted from: https://github.com/substack/node-resolve
*/
import { Config } from '@jest/types';
declare type NodeModulesPathsOptions = {
moduleDirectory?: Array<string>;
paths?: Array<Config.Path>;
};
export default function nodeModulesPaths(basedir: Config.Path, options: NodeModulesPathsOptions): Array<Config.Path>;
export {};
//# sourceMappingURL=nodeModulesPaths.d.ts.map

View file

@ -1 +0,0 @@
{"version":3,"file":"nodeModulesPaths.d.ts","sourceRoot":"","sources":["../src/nodeModulesPaths.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAGnC,aAAK,uBAAuB,GAAG;IAC7B,eAAe,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAChC,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;CAC5B,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,OAAO,EAAE,MAAM,CAAC,IAAI,EACpB,OAAO,EAAE,uBAAuB,GAC/B,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAmDpB"}

View file

@ -1,92 +0,0 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = nodeModulesPaths;
function _path() {
const data = _interopRequireDefault(require('path'));
_path = function _path() {
return data;
};
return data;
}
function _realpathNative() {
const data = require('realpath-native');
_realpathNative = function _realpathNative() {
return data;
};
return data;
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* Adapted from: https://github.com/substack/node-resolve
*/
function nodeModulesPaths(basedir, options) {
const modules =
options && options.moduleDirectory
? Array.from(options.moduleDirectory)
: ['node_modules']; // ensure that `basedir` is an absolute path at this point,
// resolving against the process' current working directory
const basedirAbs = _path().default.resolve(basedir);
let prefix = '/';
if (/^([A-Za-z]:)/.test(basedirAbs)) {
prefix = '';
} else if (/^\\\\/.test(basedirAbs)) {
prefix = '\\\\';
} // The node resolution algorithm (as implemented by NodeJS and TypeScript)
// traverses parents of the physical path, not the symlinked path
let physicalBasedir;
try {
physicalBasedir = (0, _realpathNative().sync)(basedirAbs);
} catch (err) {
// realpath can throw, e.g. on mapped drives
physicalBasedir = basedirAbs;
}
const paths = [physicalBasedir];
let parsed = _path().default.parse(physicalBasedir);
while (parsed.dir !== paths[paths.length - 1]) {
paths.push(parsed.dir);
parsed = _path().default.parse(parsed.dir);
}
const dirs = paths
.reduce(
(dirs, aPath) =>
dirs.concat(
modules.map(moduleDir =>
_path().default.isAbsolute(moduleDir)
? aPath === basedirAbs
? moduleDir
: ''
: _path().default.join(prefix, aPath, moduleDir)
)
),
[]
)
.filter(dir => dir !== '');
return options.paths ? dirs.concat(options.paths) : dirs;
}

View file

@ -1,25 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { Config } from '@jest/types';
export declare type ResolverConfig = {
browser?: boolean;
defaultPlatform?: string | null;
extensions: Array<string>;
hasCoreModules: boolean;
moduleDirectories: Array<string>;
moduleNameMapper?: Array<ModuleNameMapperConfig> | null;
modulePaths: Array<Config.Path>;
platforms?: Array<string>;
resolver?: Config.Path | null;
rootDir: Config.Path;
};
declare type ModuleNameMapperConfig = {
regex: RegExp;
moduleName: string;
};
export {};
//# sourceMappingURL=types.d.ts.map

View file

@ -1 +0,0 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAEnC,oBAAY,cAAc,GAAG;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,cAAc,EAAE,OAAO,CAAC;IACxB,iBAAiB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACjC,gBAAgB,CAAC,EAAE,KAAK,CAAC,sBAAsB,CAAC,GAAG,IAAI,CAAC;IACxD,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAChC,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC;CACtB,CAAC;AAEF,aAAK,sBAAsB,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC"}

View file

@ -1 +0,0 @@
'use strict';

View file

@ -1,34 +0,0 @@
{
"name": "jest-resolve",
"version": "24.8.0",
"repository": {
"type": "git",
"url": "https://github.com/facebook/jest.git",
"directory": "packages/jest-resolve"
},
"license": "MIT",
"main": "build/index.js",
"types": "build/index.d.ts",
"dependencies": {
"@jest/types": "^24.8.0",
"browser-resolve": "^1.11.3",
"chalk": "^2.0.1",
"jest-pnp-resolver": "^1.2.1",
"realpath-native": "^1.1.0"
},
"devDependencies": {
"@types/browser-resolve": "^0.0.5",
"jest-haste-map": "^24.8.0"
},
"engines": {
"node": ">= 6"
},
"publishConfig": {
"access": "public"
},
"gitHead": "845728f24b3ef41e450595c384e9b5c9fdf248a4"
,"_resolved": "https://registry.npmjs.org/jest-resolve/-/jest-resolve-24.8.0.tgz"
,"_integrity": "sha512-+hjSzi1PoRvnuOICoYd5V/KpIQmkAsfjFO71458hQ2Whi/yf1GDeBOFj8Gxw4LrApHsVJvn5fmjcPdmoUHaVKw=="
,"_from": "jest-resolve@24.8.0"
}

View file

@ -1,8 +0,0 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "build"
},
"references": [{"path": "../jest-types"}, {"path": "../jest-haste-map"}]
}