Updating NPM dependencies
This commit is contained in:
507
node_modules/jest-haste-map/build/index.js
generated
vendored
507
node_modules/jest-haste-map/build/index.js
generated
vendored
@@ -3,7 +3,7 @@
|
||||
function _child_process() {
|
||||
const data = require('child_process');
|
||||
|
||||
_child_process = function _child_process() {
|
||||
_child_process = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -11,9 +11,9 @@ function _child_process() {
|
||||
}
|
||||
|
||||
function _crypto() {
|
||||
const data = _interopRequireDefault(require('crypto'));
|
||||
const data = require('crypto');
|
||||
|
||||
_crypto = function _crypto() {
|
||||
_crypto = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -21,9 +21,9 @@ function _crypto() {
|
||||
}
|
||||
|
||||
function _events() {
|
||||
const data = _interopRequireDefault(require('events'));
|
||||
const data = require('events');
|
||||
|
||||
_events = function _events() {
|
||||
_events = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -31,19 +31,19 @@ function _events() {
|
||||
}
|
||||
|
||||
function _os() {
|
||||
const data = _interopRequireDefault(require('os'));
|
||||
const data = require('os');
|
||||
|
||||
_os = function _os() {
|
||||
_os = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require('path'));
|
||||
function path() {
|
||||
const data = _interopRequireWildcard(require('path'));
|
||||
|
||||
_path = function _path() {
|
||||
path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -51,19 +51,19 @@ function _path() {
|
||||
}
|
||||
|
||||
function _sane() {
|
||||
const data = _interopRequireDefault(require('sane'));
|
||||
const data = require('sane');
|
||||
|
||||
_sane = function _sane() {
|
||||
_sane = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _invariant() {
|
||||
const data = _interopRequireDefault(require('invariant'));
|
||||
function _jestRegexUtil() {
|
||||
const data = require('jest-regex-util');
|
||||
|
||||
_invariant = function _invariant() {
|
||||
_jestRegexUtil = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -73,7 +73,7 @@ function _invariant() {
|
||||
function _jestSerializer() {
|
||||
const data = _interopRequireDefault(require('jest-serializer'));
|
||||
|
||||
_jestSerializer = function _jestSerializer() {
|
||||
_jestSerializer = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -83,141 +83,85 @@ function _jestSerializer() {
|
||||
function _jestWorker() {
|
||||
const data = _interopRequireDefault(require('jest-worker'));
|
||||
|
||||
_jestWorker = function _jestWorker() {
|
||||
_jestWorker = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _worker = require('./worker');
|
||||
var _HasteFS = _interopRequireDefault(require('./HasteFS'));
|
||||
|
||||
var _ModuleMap = _interopRequireDefault(require('./ModuleMap'));
|
||||
|
||||
var _constants = _interopRequireDefault(require('./constants'));
|
||||
|
||||
var _node = _interopRequireDefault(require('./crawlers/node'));
|
||||
|
||||
var _watchman = _interopRequireDefault(require('./crawlers/watchman'));
|
||||
|
||||
var _getMockName = _interopRequireDefault(require('./getMockName'));
|
||||
|
||||
var _FSEventsWatcher = _interopRequireDefault(require('./lib/FSEventsWatcher'));
|
||||
|
||||
var _WatchmanWatcher = _interopRequireDefault(require('./lib/WatchmanWatcher'));
|
||||
|
||||
var fastPath = _interopRequireWildcard(require('./lib/fast_path'));
|
||||
|
||||
var _getPlatformExtension = _interopRequireDefault(
|
||||
require('./lib/getPlatformExtension')
|
||||
);
|
||||
|
||||
var _constants = _interopRequireDefault(require('./constants'));
|
||||
|
||||
var _HasteFS = _interopRequireDefault(require('./HasteFS'));
|
||||
|
||||
var _ModuleMap = _interopRequireDefault(require('./ModuleMap'));
|
||||
|
||||
var _node = _interopRequireDefault(require('./crawlers/node'));
|
||||
|
||||
var _normalizePathSep = _interopRequireDefault(
|
||||
require('./lib/normalizePathSep')
|
||||
);
|
||||
|
||||
var _watchman = _interopRequireDefault(require('./crawlers/watchman'));
|
||||
|
||||
var _WatchmanWatcher = _interopRequireDefault(require('./lib/WatchmanWatcher'));
|
||||
|
||||
var _FSEventsWatcher = _interopRequireDefault(require('./lib/FSEventsWatcher'));
|
||||
|
||||
var fastPath = _interopRequireWildcard(require('./lib/fast_path'));
|
||||
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
} else {
|
||||
var newObj = {};
|
||||
if (obj != null) {
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor
|
||||
? Object.getOwnPropertyDescriptor(obj, key)
|
||||
: {};
|
||||
if (desc.get || desc.set) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
return newObj;
|
||||
}
|
||||
}
|
||||
var _worker = require('./worker');
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
function _slicedToArray(arr, i) {
|
||||
return (
|
||||
_arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest()
|
||||
);
|
||||
}
|
||||
|
||||
function _nonIterableRest() {
|
||||
throw new TypeError('Invalid attempt to destructure non-iterable instance');
|
||||
}
|
||||
|
||||
function _iterableToArrayLimit(arr, i) {
|
||||
var _arr = [];
|
||||
var _n = true;
|
||||
var _d = false;
|
||||
var _e = undefined;
|
||||
try {
|
||||
for (
|
||||
var _i = arr[Symbol.iterator](), _s;
|
||||
!(_n = (_s = _i.next()).done);
|
||||
_n = true
|
||||
) {
|
||||
_arr.push(_s.value);
|
||||
if (i && _arr.length === i) break;
|
||||
}
|
||||
} catch (err) {
|
||||
_d = true;
|
||||
_e = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_n && _i['return'] != null) _i['return']();
|
||||
} finally {
|
||||
if (_d) throw _e;
|
||||
}
|
||||
}
|
||||
return _arr;
|
||||
}
|
||||
|
||||
function _arrayWithHoles(arr) {
|
||||
if (Array.isArray(arr)) return arr;
|
||||
}
|
||||
|
||||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
||||
try {
|
||||
var info = gen[key](arg);
|
||||
var value = info.value;
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
if (info.done) {
|
||||
resolve(value);
|
||||
} else {
|
||||
Promise.resolve(value).then(_next, _throw);
|
||||
}
|
||||
}
|
||||
|
||||
function _asyncToGenerator(fn) {
|
||||
return function() {
|
||||
var self = this,
|
||||
args = arguments;
|
||||
return new Promise(function(resolve, reject) {
|
||||
var gen = fn.apply(self, args);
|
||||
function _next(value) {
|
||||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'next', value);
|
||||
}
|
||||
function _throw(err) {
|
||||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'throw', err);
|
||||
}
|
||||
_next(undefined);
|
||||
});
|
||||
function _getRequireWildcardCache() {
|
||||
if (typeof WeakMap !== 'function') return null;
|
||||
var cache = new WeakMap();
|
||||
_getRequireWildcardCache = function () {
|
||||
return cache;
|
||||
};
|
||||
return cache;
|
||||
}
|
||||
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
return {default: obj};
|
||||
}
|
||||
var cache = _getRequireWildcardCache();
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = hasPropertyDescriptor
|
||||
? Object.getOwnPropertyDescriptor(obj, key)
|
||||
: null;
|
||||
if (desc && (desc.get || desc.set)) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
if (cache) {
|
||||
cache.set(obj, newObj);
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
|
||||
function _defineProperty(obj, key, value) {
|
||||
@@ -234,16 +178,19 @@ function _defineProperty(obj, key, value) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
// TypeScript doesn't like us importing from outside `rootDir`, but it doesn't
|
||||
// understand `require`.
|
||||
const {version: VERSION} = require('../package.json');
|
||||
|
||||
const CHANGE_INTERVAL = 30;
|
||||
const MAX_WAIT_TIME = 240000;
|
||||
|
||||
const NODE_MODULES = _path().default.sep + 'node_modules' + _path().default.sep;
|
||||
|
||||
const PACKAGE_JSON = _path().default.sep + 'package.json'; // TypeScript doesn't like us importing from outside `rootDir`, but it doesn't
|
||||
// understand `require`.
|
||||
|
||||
const _require = require('../package.json'),
|
||||
VERSION = _require.version;
|
||||
const NODE_MODULES = path().sep + 'node_modules' + path().sep;
|
||||
const PACKAGE_JSON = path().sep + 'package.json';
|
||||
const VCS_DIRECTORIES = ['.git', '.hg']
|
||||
.map(vcs =>
|
||||
(0, _jestRegexUtil().escapePathForRegex)(path().sep + vcs + path().sep)
|
||||
)
|
||||
.join('|');
|
||||
|
||||
const canUseWatchman = (() => {
|
||||
try {
|
||||
@@ -251,33 +198,16 @@ const canUseWatchman = (() => {
|
||||
stdio: ['ignore']
|
||||
});
|
||||
return true;
|
||||
} catch (e) {}
|
||||
} catch {}
|
||||
|
||||
return false;
|
||||
})();
|
||||
|
||||
const escapePathSeparator = string =>
|
||||
_path().default.sep === '\\' ? string.replace(/(\/|\\)/g, '\\\\') : string;
|
||||
|
||||
const getWhiteList = list => {
|
||||
if (list && list.length) {
|
||||
const newList = list.map(item =>
|
||||
escapePathSeparator(item.replace(/(\/)/g, _path().default.sep))
|
||||
);
|
||||
return new RegExp(
|
||||
'(' +
|
||||
escapePathSeparator(NODE_MODULES) +
|
||||
'(?:' +
|
||||
newList.join('|') +
|
||||
')(?=$|' +
|
||||
escapePathSeparator(_path().default.sep) +
|
||||
'))',
|
||||
'g'
|
||||
);
|
||||
function invariant(condition, message) {
|
||||
if (!condition) {
|
||||
throw new Error(message);
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* HasteMap is a JavaScript implementation of Facebook's haste module system.
|
||||
*
|
||||
@@ -357,9 +287,7 @@ const getWhiteList = list => {
|
||||
*
|
||||
*/
|
||||
|
||||
/* eslint-disable-next-line no-redeclare */
|
||||
|
||||
class HasteMap extends _events().default {
|
||||
class HasteMap extends _events().EventEmitter {
|
||||
constructor(options) {
|
||||
super();
|
||||
|
||||
@@ -375,23 +303,19 @@ class HasteMap extends _events().default {
|
||||
|
||||
_defineProperty(this, '_watchers', void 0);
|
||||
|
||||
_defineProperty(this, '_whitelist', void 0);
|
||||
|
||||
_defineProperty(this, '_worker', void 0);
|
||||
|
||||
this._options = {
|
||||
cacheDirectory: options.cacheDirectory || _os().default.tmpdir(),
|
||||
cacheDirectory: options.cacheDirectory || (0, _os().tmpdir)(),
|
||||
computeDependencies:
|
||||
options.computeDependencies === undefined
|
||||
? true
|
||||
: options.computeDependencies,
|
||||
computeSha1: options.computeSha1 || false,
|
||||
dependencyExtractor: options.dependencyExtractor,
|
||||
dependencyExtractor: options.dependencyExtractor || null,
|
||||
extensions: options.extensions,
|
||||
forceNodeFilesystemAPI: !!options.forceNodeFilesystemAPI,
|
||||
hasteImplModulePath: options.hasteImplModulePath,
|
||||
ignorePattern: options.ignorePattern,
|
||||
mapper: options.mapper,
|
||||
maxWorkers: options.maxWorkers,
|
||||
mocksPattern: options.mocksPattern
|
||||
? new RegExp(options.mocksPattern)
|
||||
@@ -409,18 +333,31 @@ class HasteMap extends _events().default {
|
||||
};
|
||||
this._console = options.console || global.console;
|
||||
|
||||
if (options.ignorePattern && !(options.ignorePattern instanceof RegExp)) {
|
||||
this._console.warn(
|
||||
'jest-haste-map: the `ignorePattern` options as a function is being ' +
|
||||
'deprecated. Provide a RegExp instead. See https://github.com/facebook/jest/pull/4063.'
|
||||
);
|
||||
if (options.ignorePattern) {
|
||||
if (options.ignorePattern instanceof RegExp) {
|
||||
this._options.ignorePattern = new RegExp(
|
||||
options.ignorePattern.source.concat('|' + VCS_DIRECTORIES),
|
||||
options.ignorePattern.flags
|
||||
);
|
||||
} else {
|
||||
const ignorePattern = options.ignorePattern;
|
||||
const vcsIgnoreRegExp = new RegExp(VCS_DIRECTORIES);
|
||||
|
||||
this._options.ignorePattern = filePath =>
|
||||
vcsIgnoreRegExp.test(filePath) || ignorePattern(filePath);
|
||||
|
||||
this._console.warn(
|
||||
'jest-haste-map: the `ignorePattern` options as a function is being ' +
|
||||
'deprecated. Provide a RegExp instead. See https://github.com/facebook/jest/pull/4063.'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
this._options.ignorePattern = new RegExp(VCS_DIRECTORIES);
|
||||
}
|
||||
|
||||
const rootDirHash = _crypto()
|
||||
.default.createHash('md5')
|
||||
const rootDirHash = (0, _crypto().createHash)('md5')
|
||||
.update(options.rootDir)
|
||||
.digest('hex');
|
||||
|
||||
let hasteImplHash = '';
|
||||
let dependencyExtractorHash = '';
|
||||
|
||||
@@ -456,18 +393,14 @@ class HasteMap extends _events().default {
|
||||
hasteImplHash,
|
||||
dependencyExtractorHash
|
||||
);
|
||||
this._whitelist = getWhiteList(options.providesModuleNodeModules);
|
||||
this._buildPromise = null;
|
||||
this._watchers = [];
|
||||
this._worker = null;
|
||||
}
|
||||
|
||||
static getCacheFilePath(tmpdir, name, ...extra) {
|
||||
const hash = _crypto()
|
||||
.default.createHash('md5')
|
||||
.update(extra.join(''));
|
||||
|
||||
return _path().default.join(
|
||||
const hash = (0, _crypto().createHash)('md5').update(extra.join(''));
|
||||
return path().join(
|
||||
tmpdir,
|
||||
name.replace(/\W/g, '-') + '-' + hash.digest('hex')
|
||||
);
|
||||
@@ -478,11 +411,9 @@ class HasteMap extends _events().default {
|
||||
}
|
||||
|
||||
build() {
|
||||
var _this = this;
|
||||
|
||||
if (!this._buildPromise) {
|
||||
this._buildPromise = _asyncToGenerator(function*() {
|
||||
const data = yield _this._buildFileMap(); // Persist when we don't know if files changed (changedFiles undefined)
|
||||
this._buildPromise = (async () => {
|
||||
const data = await this._buildFileMap(); // Persist when we don't know if files changed (changedFiles undefined)
|
||||
// or when we know a file was changed or deleted.
|
||||
|
||||
let hasteMap;
|
||||
@@ -492,14 +423,14 @@ class HasteMap extends _events().default {
|
||||
data.changedFiles.size > 0 ||
|
||||
data.removedFiles.size > 0
|
||||
) {
|
||||
hasteMap = yield _this._buildHasteMap(data);
|
||||
hasteMap = await this._buildHasteMap(data);
|
||||
|
||||
_this._persist(hasteMap);
|
||||
this._persist(hasteMap);
|
||||
} else {
|
||||
hasteMap = data.hasteMap;
|
||||
}
|
||||
|
||||
const rootDir = _this._options.rootDir;
|
||||
const rootDir = this._options.rootDir;
|
||||
const hasteFS = new _HasteFS.default({
|
||||
files: hasteMap.files,
|
||||
rootDir
|
||||
@@ -514,7 +445,7 @@ class HasteMap extends _events().default {
|
||||
const __hasteMapForTest =
|
||||
(process.env.NODE_ENV === 'test' && hasteMap) || null;
|
||||
|
||||
yield _this._watch(hasteMap);
|
||||
await this._watch(hasteMap);
|
||||
return {
|
||||
__hasteMapForTest,
|
||||
hasteFS,
|
||||
@@ -534,7 +465,7 @@ class HasteMap extends _events().default {
|
||||
|
||||
try {
|
||||
hasteMap = _jestSerializer().default.readFileSync(this._cachePath);
|
||||
} catch (err) {
|
||||
} catch {
|
||||
hasteMap = this._createEmptyMap();
|
||||
}
|
||||
|
||||
@@ -554,23 +485,17 @@ class HasteMap extends _events().default {
|
||||
* 2. crawl the file system.
|
||||
*/
|
||||
|
||||
_buildFileMap() {
|
||||
var _this2 = this;
|
||||
async _buildFileMap() {
|
||||
let hasteMap;
|
||||
|
||||
return _asyncToGenerator(function*() {
|
||||
let hasteMap;
|
||||
try {
|
||||
const read = this._options.resetCache ? this._createEmptyMap : this.read;
|
||||
hasteMap = await read.call(this);
|
||||
} catch {
|
||||
hasteMap = this._createEmptyMap();
|
||||
}
|
||||
|
||||
try {
|
||||
const read = _this2._options.resetCache
|
||||
? _this2._createEmptyMap
|
||||
: _this2.read;
|
||||
hasteMap = yield read.call(_this2);
|
||||
} catch (_unused) {
|
||||
hasteMap = _this2._createEmptyMap();
|
||||
}
|
||||
|
||||
return _this2._crawl(hasteMap);
|
||||
})();
|
||||
return this._crawl(hasteMap);
|
||||
}
|
||||
/**
|
||||
* 3. parse and extract metadata from changed files.
|
||||
@@ -607,11 +532,9 @@ class HasteMap extends _events().default {
|
||||
'jest-haste-map: Haste module naming collision: ' + id,
|
||||
' The following files share their name; please adjust your hasteImpl:',
|
||||
' * <rootDir>' +
|
||||
_path().default.sep +
|
||||
path().sep +
|
||||
existingModule[_constants.default.PATH],
|
||||
' * <rootDir>' +
|
||||
_path().default.sep +
|
||||
module[_constants.default.PATH],
|
||||
' * <rootDir>' + path().sep + module[_constants.default.PATH],
|
||||
''
|
||||
].join('\n')
|
||||
);
|
||||
@@ -704,7 +627,7 @@ class HasteMap extends _events().default {
|
||||
if (typeof error !== 'object' || !error.message || !error.stack) {
|
||||
error = new Error(error);
|
||||
error.stack = ''; // Remove stack for stack-less errors.
|
||||
} // @ts-ignore: checking error code is OK if error comes from "fs".
|
||||
}
|
||||
|
||||
if (!['ENOENT', 'EACCES'].includes(error.code)) {
|
||||
throw error;
|
||||
@@ -715,7 +638,7 @@ class HasteMap extends _events().default {
|
||||
}; // If we retain all files in the virtual HasteFS representation, we avoid
|
||||
// reading them if they aren't important (node_modules).
|
||||
|
||||
if (this._options.retainAllFiles && this._isNodeModulesDir(filePath)) {
|
||||
if (this._options.retainAllFiles && filePath.includes(NODE_MODULES)) {
|
||||
if (computeSha1) {
|
||||
return this._getWorker(workerOptions)
|
||||
.getSha1({
|
||||
@@ -751,8 +674,8 @@ class HasteMap extends _events().default {
|
||||
[
|
||||
'jest-haste-map: duplicate manual mock found: ' + mockPath,
|
||||
' The following files share their name; please delete one of them:',
|
||||
' * <rootDir>' + _path().default.sep + existingMockPath,
|
||||
' * <rootDir>' + _path().default.sep + secondMockPath,
|
||||
' * <rootDir>' + path().sep + existingMockPath,
|
||||
' * <rootDir>' + path().sep + secondMockPath,
|
||||
''
|
||||
].join('\n')
|
||||
);
|
||||
@@ -810,9 +733,7 @@ class HasteMap extends _events().default {
|
||||
}
|
||||
|
||||
_buildHasteMap(data) {
|
||||
const removedFiles = data.removedFiles,
|
||||
changedFiles = data.changedFiles,
|
||||
hasteMap = data.hasteMap; // If any files were removed or we did not track what files changed, process
|
||||
const {removedFiles, changedFiles, hasteMap} = data; // If any files were removed or we did not track what files changed, process
|
||||
// every file looking for changes. Otherwise, process only changed files.
|
||||
|
||||
let map;
|
||||
@@ -829,84 +750,33 @@ class HasteMap extends _events().default {
|
||||
filesToProcess = changedFiles;
|
||||
}
|
||||
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (
|
||||
var _iterator = removedFiles[Symbol.iterator](), _step;
|
||||
!(_iteratorNormalCompletion = (_step = _iterator.next()).done);
|
||||
_iteratorNormalCompletion = true
|
||||
) {
|
||||
const _step$value = _slicedToArray(_step.value, 2),
|
||||
relativeFilePath = _step$value[0],
|
||||
fileMetadata = _step$value[1];
|
||||
|
||||
this._recoverDuplicates(
|
||||
hasteMap,
|
||||
relativeFilePath,
|
||||
fileMetadata[_constants.default.ID]
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
for (const [relativeFilePath, fileMetadata] of removedFiles) {
|
||||
this._recoverDuplicates(
|
||||
hasteMap,
|
||||
relativeFilePath,
|
||||
fileMetadata[_constants.default.ID]
|
||||
);
|
||||
}
|
||||
|
||||
const promises = [];
|
||||
var _iteratorNormalCompletion2 = true;
|
||||
var _didIteratorError2 = false;
|
||||
var _iteratorError2 = undefined;
|
||||
|
||||
try {
|
||||
for (
|
||||
var _iterator2 = filesToProcess.keys()[Symbol.iterator](), _step2;
|
||||
!(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done);
|
||||
_iteratorNormalCompletion2 = true
|
||||
for (const relativeFilePath of filesToProcess.keys()) {
|
||||
if (
|
||||
this._options.skipPackageJson &&
|
||||
relativeFilePath.endsWith(PACKAGE_JSON)
|
||||
) {
|
||||
const relativeFilePath = _step2.value;
|
||||
continue;
|
||||
} // SHA-1, if requested, should already be present thanks to the crawler.
|
||||
|
||||
if (
|
||||
this._options.skipPackageJson &&
|
||||
relativeFilePath.endsWith(PACKAGE_JSON)
|
||||
) {
|
||||
continue;
|
||||
} // SHA-1, if requested, should already be present thanks to the crawler.
|
||||
const filePath = fastPath.resolve(
|
||||
this._options.rootDir,
|
||||
relativeFilePath
|
||||
);
|
||||
|
||||
const filePath = fastPath.resolve(
|
||||
this._options.rootDir,
|
||||
relativeFilePath
|
||||
);
|
||||
const promise = this._processFile(hasteMap, map, mocks, filePath);
|
||||
|
||||
const promise = this._processFile(hasteMap, map, mocks, filePath);
|
||||
|
||||
if (promise) {
|
||||
promises.push(promise);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError2 = true;
|
||||
_iteratorError2 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
||||
_iterator2.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError2) {
|
||||
throw _iteratorError2;
|
||||
}
|
||||
if (promise) {
|
||||
promises.push(promise);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -927,10 +797,10 @@ class HasteMap extends _events().default {
|
||||
}
|
||||
|
||||
_cleanup() {
|
||||
const worker = this._worker; // @ts-ignore
|
||||
const worker = this._worker; // @ts-expect-error
|
||||
|
||||
if (worker && typeof worker.end === 'function') {
|
||||
// @ts-ignore
|
||||
// @ts-expect-error
|
||||
worker.end();
|
||||
}
|
||||
|
||||
@@ -955,8 +825,8 @@ class HasteMap extends _events().default {
|
||||
worker: _worker.worker
|
||||
};
|
||||
} else {
|
||||
// @ts-ignore: assignment of a worker with custom properties.
|
||||
this._worker = new (_jestWorker()).default(
|
||||
// @ts-expect-error: assignment of a worker with custom properties.
|
||||
this._worker = new (_jestWorker().default)(
|
||||
require.resolve('./worker'),
|
||||
{
|
||||
exposedMethods: ['getSha1', 'worker'],
|
||||
@@ -985,7 +855,6 @@ class HasteMap extends _events().default {
|
||||
extensions: options.extensions,
|
||||
forceNodeFilesystemAPI: options.forceNodeFilesystemAPI,
|
||||
ignore,
|
||||
mapper: options.mapper,
|
||||
rootDir: options.rootDir,
|
||||
roots: options.roots
|
||||
};
|
||||
@@ -1038,7 +907,7 @@ class HasteMap extends _events().default {
|
||||
? _WatchmanWatcher.default
|
||||
: _FSEventsWatcher.default.isSupported()
|
||||
? _FSEventsWatcher.default
|
||||
: _sane().default.NodeWatcher;
|
||||
: _sane().NodeWatcher;
|
||||
const extensions = this._options.extensions;
|
||||
const ignorePattern = this._options.ignorePattern;
|
||||
const rootDir = this._options.rootDir;
|
||||
@@ -1048,9 +917,9 @@ class HasteMap extends _events().default {
|
||||
let mustCopy = true;
|
||||
|
||||
const createWatcher = root => {
|
||||
// @ts-ignore: TODO how? "Cannot use 'new' with an expression whose type lacks a call or construct signature."
|
||||
// @ts-expect-error: TODO how? "Cannot use 'new' with an expression whose type lacks a call or construct signature."
|
||||
const watcher = new Watcher(root, {
|
||||
dot: false,
|
||||
dot: true,
|
||||
glob: extensions.map(extension => '**/*.' + extension),
|
||||
ignored: ignorePattern
|
||||
});
|
||||
@@ -1089,10 +958,7 @@ class HasteMap extends _events().default {
|
||||
};
|
||||
|
||||
const onChange = (type, filePath, root, stat) => {
|
||||
filePath = _path().default.join(
|
||||
root,
|
||||
(0, _normalizePathSep.default)(filePath)
|
||||
);
|
||||
filePath = path().join(root, (0, _normalizePathSep.default)(filePath));
|
||||
|
||||
if (
|
||||
(stat && stat.isDirectory()) ||
|
||||
@@ -1102,6 +968,18 @@ class HasteMap extends _events().default {
|
||||
return;
|
||||
}
|
||||
|
||||
const relativeFilePath = fastPath.relative(rootDir, filePath);
|
||||
const fileMetadata = hasteMap.files.get(relativeFilePath); // The file has been accessed, not modified
|
||||
|
||||
if (
|
||||
type === 'change' &&
|
||||
fileMetadata &&
|
||||
stat &&
|
||||
fileMetadata[_constants.default.MTIME] === stat.mtime.getTime()
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
changeQueue = changeQueue
|
||||
.then(() => {
|
||||
// If we get duplicate events for the same file, ignore them.
|
||||
@@ -1139,7 +1017,6 @@ class HasteMap extends _events().default {
|
||||
return null;
|
||||
};
|
||||
|
||||
const relativeFilePath = fastPath.relative(rootDir, filePath);
|
||||
const fileMetadata = hasteMap.files.get(relativeFilePath); // If it's not an addition, delete the file and all its metadata
|
||||
|
||||
if (fileMetadata != null) {
|
||||
@@ -1180,14 +1057,14 @@ class HasteMap extends _events().default {
|
||||
// parse it and update the haste map.
|
||||
|
||||
if (type === 'add' || type === 'change') {
|
||||
(0, _invariant().default)(
|
||||
invariant(
|
||||
stat,
|
||||
'since the file exists or changed, it should have stats'
|
||||
);
|
||||
const fileMetadata = [
|
||||
'',
|
||||
stat ? stat.mtime.getTime() : -1,
|
||||
stat ? stat.size : 0,
|
||||
stat.mtime.getTime(),
|
||||
stat.size,
|
||||
0,
|
||||
'',
|
||||
null
|
||||
@@ -1293,7 +1170,7 @@ class HasteMap extends _events().default {
|
||||
}
|
||||
|
||||
end() {
|
||||
// @ts-ignore: TODO TS cannot decide if `setInterval` and `clearInterval` comes from NodeJS or the DOM
|
||||
// @ts-expect-error: TODO TS cannot decide if `setInterval` and `clearInterval` comes from NodeJS or the DOM
|
||||
clearInterval(this._changeInterval);
|
||||
|
||||
if (!this._watchers.length) {
|
||||
@@ -1320,32 +1197,10 @@ class HasteMap extends _events().default {
|
||||
: ignorePattern && ignorePattern(filePath);
|
||||
return (
|
||||
ignoreMatched ||
|
||||
(!this._options.retainAllFiles && this._isNodeModulesDir(filePath))
|
||||
(!this._options.retainAllFiles && filePath.includes(NODE_MODULES))
|
||||
);
|
||||
}
|
||||
|
||||
_isNodeModulesDir(filePath) {
|
||||
if (!filePath.includes(NODE_MODULES)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this._whitelist) {
|
||||
const whitelist = this._whitelist;
|
||||
const match = whitelist.exec(filePath);
|
||||
const matchEndIndex = whitelist.lastIndex;
|
||||
whitelist.lastIndex = 0;
|
||||
|
||||
if (!match) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const filePathInPackage = filePath.substr(matchEndIndex);
|
||||
return filePathInPackage.startsWith(NODE_MODULES);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
_createEmptyMap() {
|
||||
return {
|
||||
clocks: new Map(),
|
||||
|
||||
Reference in New Issue
Block a user