jest-util
Advanced tools
Comparing version 29.1.2 to 29.2.0
@@ -7,3 +7,2 @@ 'use strict'; | ||
exports.default = clearLine; | ||
/** | ||
@@ -15,2 +14,3 @@ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
*/ | ||
function clearLine(stream) { | ||
@@ -17,0 +17,0 @@ if (stream.isTTY) { |
@@ -7,3 +7,2 @@ 'use strict'; | ||
exports.default = convertDescriptorToString; | ||
/** | ||
@@ -15,2 +14,3 @@ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
*/ | ||
function convertDescriptorToString(descriptor) { | ||
@@ -22,13 +22,9 @@ switch (typeof descriptor) { | ||
} | ||
break; | ||
case 'number': | ||
case 'undefined': | ||
return `${descriptor}`; | ||
case 'string': | ||
return descriptor; | ||
} | ||
throw new Error( | ||
@@ -35,0 +31,0 @@ `Invalid first argument, ${descriptor}. It must be a named class, named function, number, or string.` |
@@ -7,13 +7,9 @@ 'use strict'; | ||
exports.default = createDirectory; | ||
function fs() { | ||
const data = _interopRequireWildcard(require('graceful-fs')); | ||
fs = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _getRequireWildcardCache(nodeInterop) { | ||
@@ -27,3 +23,2 @@ if (typeof WeakMap !== 'function') return null; | ||
} | ||
function _interopRequireWildcard(obj, nodeInterop) { | ||
@@ -61,3 +56,2 @@ if (!nodeInterop && obj && obj.__esModule) { | ||
} | ||
/** | ||
@@ -69,2 +63,3 @@ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
*/ | ||
function createDirectory(path) { | ||
@@ -71,0 +66,0 @@ try { |
@@ -7,9 +7,6 @@ 'use strict'; | ||
exports.default = createProcessObject; | ||
var _deepCyclicCopy = _interopRequireDefault(require('./deepCyclicCopy')); | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
/** | ||
@@ -21,5 +18,8 @@ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
*/ | ||
const BLACKLIST = new Set(['env', 'mainModule', '_events']); | ||
const isWin32 = process.platform === 'win32'; | ||
const proto = Object.getPrototypeOf(process.env); // The "process.env" object has a bunch of particularities: first, it does not | ||
const proto = Object.getPrototypeOf(process.env); | ||
// The "process.env" object has a bunch of particularities: first, it does not | ||
// directly extend from Object; second, it converts any assigned value to a | ||
@@ -32,3 +32,2 @@ // string; and third, it is case-insensitive in Windows. We use a proxy here to | ||
const lookup = {}; | ||
function deletePropertyWin32(_target, key) { | ||
@@ -50,6 +49,4 @@ for (const name in real) { | ||
} | ||
return true; | ||
} | ||
function deleteProperty(_target, key) { | ||
@@ -60,7 +57,5 @@ delete real[key]; | ||
} | ||
function getProperty(_target, key) { | ||
return real[key]; | ||
} | ||
function getPropertyWin32(_target, key) { | ||
@@ -73,14 +68,10 @@ if (typeof key === 'string') { | ||
} | ||
const proxy = new Proxy(real, { | ||
deleteProperty: isWin32 ? deletePropertyWin32 : deleteProperty, | ||
get: isWin32 ? getPropertyWin32 : getProperty, | ||
set(_target, key, value) { | ||
const strValue = `${value}`; | ||
if (typeof key === 'string') { | ||
lookup[key.toLowerCase()] = strValue; | ||
} | ||
real[key] = strValue; | ||
@@ -92,6 +83,4 @@ return true; | ||
} | ||
function createProcessObject() { | ||
const process = require('process'); | ||
const newProcess = (0, _deepCyclicCopy.default)(process, { | ||
@@ -101,3 +90,2 @@ blacklist: BLACKLIST, | ||
}); | ||
try { | ||
@@ -112,6 +100,6 @@ // This fails on Node 12, but it's already set to 'process' | ||
} | ||
} // Sequentially execute all constructors over the object. | ||
} | ||
// Sequentially execute all constructors over the object. | ||
let proto = process; | ||
while ((proto = Object.getPrototypeOf(proto))) { | ||
@@ -122,7 +110,4 @@ if (typeof proto.constructor === 'function') { | ||
} | ||
newProcess.env = createProcessEnv(); | ||
newProcess.send = () => true; | ||
Object.defineProperty(newProcess, 'domain', { | ||
@@ -129,0 +114,0 @@ get() { |
@@ -7,3 +7,2 @@ 'use strict'; | ||
exports.default = deepCyclicCopy; | ||
/** | ||
@@ -15,4 +14,4 @@ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
*/ | ||
const EMPTY = new Set(); | ||
function deepCyclicCopy( | ||
@@ -36,3 +35,2 @@ value, | ||
} | ||
function deepCyclicCopyObject(object, options, cycles) { | ||
@@ -49,5 +47,3 @@ const newObject = options.keepPrototype | ||
} | ||
const descriptor = descriptors[key]; | ||
if (typeof descriptor.value !== 'undefined') { | ||
@@ -63,3 +59,2 @@ descriptor.value = deepCyclicCopy( | ||
} | ||
descriptor.configurable = true; | ||
@@ -69,3 +64,2 @@ }); | ||
} | ||
function deepCyclicCopyArray(array, options, cycles) { | ||
@@ -77,3 +71,2 @@ const newArray = options.keepPrototype | ||
cycles.set(array, newArray); | ||
for (let i = 0; i < length; i++) { | ||
@@ -89,4 +82,3 @@ newArray[i] = deepCyclicCopy( | ||
} | ||
return newArray; | ||
} |
@@ -7,3 +7,2 @@ 'use strict'; | ||
exports.default = void 0; | ||
/** | ||
@@ -15,2 +14,3 @@ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
*/ | ||
class ErrorWithStack extends Error { | ||
@@ -20,17 +20,12 @@ constructor(message, callsite, stackLimit) { | ||
const originalStackLimit = Error.stackTraceLimit; | ||
if (stackLimit) { | ||
Error.stackTraceLimit = Math.max(stackLimit, originalStackLimit || 10); | ||
} | ||
super(message); | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(this, callsite); | ||
} | ||
Error.stackTraceLimit = originalStackLimit; | ||
} | ||
} | ||
exports.default = ErrorWithStack; |
@@ -7,3 +7,2 @@ 'use strict'; | ||
exports.default = formatTime; | ||
/** | ||
@@ -15,2 +14,3 @@ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
*/ | ||
function formatTime(time, prefixPower = -3, padLeftLength = 0) { | ||
@@ -17,0 +17,0 @@ const prefixes = ['n', 'μ', 'm', '']; |
@@ -7,21 +7,15 @@ 'use strict'; | ||
exports.default = globsToMatcher; | ||
function _picomatch() { | ||
const data = _interopRequireDefault(require('picomatch')); | ||
_picomatch = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
var _replacePathSepForGlob = _interopRequireDefault( | ||
require('./replacePathSepForGlob') | ||
); | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
/** | ||
@@ -33,2 +27,3 @@ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
*/ | ||
const globsToMatchersMap = new Map(); | ||
@@ -38,2 +33,3 @@ const picomatchOptions = { | ||
}; | ||
/** | ||
@@ -56,3 +52,2 @@ * Converts a list of globs into a function that matches a path against the | ||
*/ | ||
function globsToMatcher(globs) { | ||
@@ -64,3 +59,2 @@ if (globs.length === 0) { | ||
} | ||
const matchers = globs.map(glob => { | ||
@@ -77,3 +71,2 @@ if (!globsToMatchersMap.has(glob)) { | ||
} | ||
return globsToMatchersMap.get(glob); | ||
@@ -85,12 +78,8 @@ }); | ||
let negatives = 0; | ||
for (let i = 0; i < matchers.length; i++) { | ||
const {isMatch, negated} = matchers[i]; | ||
if (negated) { | ||
negatives++; | ||
} | ||
const matched = isMatch(replacedPath); | ||
if (!matched && negated) { | ||
@@ -106,3 +95,5 @@ // The path was not matched, and the matcher is a negated matcher, so we | ||
} | ||
} // If all of the globs were negative globs, then we want to include the path | ||
} | ||
// If all of the globs were negative globs, then we want to include the path | ||
// as long as it was not explicitly not kept. Otherwise only include | ||
@@ -113,5 +104,4 @@ // the path if it was kept. This allows sets of globs that are all negated | ||
// and not keep them. | ||
return negatives === matchers.length ? kept !== false : !!kept; | ||
}; | ||
} |
@@ -110,61 +110,38 @@ 'use strict'; | ||
}); | ||
var preRunMessage = _interopRequireWildcard(require('./preRunMessage')); | ||
exports.preRunMessage = preRunMessage; | ||
var specialChars = _interopRequireWildcard(require('./specialChars')); | ||
exports.specialChars = specialChars; | ||
var _clearLine = _interopRequireDefault2(require('./clearLine')); | ||
var _createDirectory = _interopRequireDefault2(require('./createDirectory')); | ||
var _ErrorWithStack = _interopRequireDefault2(require('./ErrorWithStack')); | ||
var _installCommonGlobals = _interopRequireDefault2( | ||
require('./installCommonGlobals') | ||
); | ||
var _interopRequireDefault = _interopRequireDefault2( | ||
require('./interopRequireDefault') | ||
); | ||
var _isInteractive = _interopRequireDefault2(require('./isInteractive')); | ||
var _isPromise = _interopRequireDefault2(require('./isPromise')); | ||
var _setGlobal = _interopRequireDefault2(require('./setGlobal')); | ||
var _deepCyclicCopy = _interopRequireDefault2(require('./deepCyclicCopy')); | ||
var _convertDescriptorToString = _interopRequireDefault2( | ||
require('./convertDescriptorToString') | ||
); | ||
var _replacePathSepForGlob = _interopRequireDefault2( | ||
require('./replacePathSepForGlob') | ||
); | ||
var _testPathPatternToRegExp = _interopRequireDefault2( | ||
require('./testPathPatternToRegExp') | ||
); | ||
var _globsToMatcher = _interopRequireDefault2(require('./globsToMatcher')); | ||
var _pluralize = _interopRequireDefault2(require('./pluralize')); | ||
var _formatTime = _interopRequireDefault2(require('./formatTime')); | ||
var _tryRealpath = _interopRequireDefault2(require('./tryRealpath')); | ||
var _requireOrImportModule = _interopRequireDefault2( | ||
require('./requireOrImportModule') | ||
); | ||
function _interopRequireDefault2(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
function _getRequireWildcardCache(nodeInterop) { | ||
@@ -178,3 +155,2 @@ if (typeof WeakMap !== 'function') return null; | ||
} | ||
function _interopRequireWildcard(obj, nodeInterop) { | ||
@@ -181,0 +157,0 @@ if (!nodeInterop && obj && obj.__esModule) { |
@@ -7,23 +7,16 @@ 'use strict'; | ||
exports.default = installCommonGlobals; | ||
function fs() { | ||
const data = _interopRequireWildcard(require('graceful-fs')); | ||
fs = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
var _createProcessObject = _interopRequireDefault( | ||
require('./createProcessObject') | ||
); | ||
var _deepCyclicCopy = _interopRequireDefault(require('./deepCyclicCopy')); | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
function _getRequireWildcardCache(nodeInterop) { | ||
@@ -37,3 +30,2 @@ if (typeof WeakMap !== 'function') return null; | ||
} | ||
function _interopRequireWildcard(obj, nodeInterop) { | ||
@@ -71,3 +63,2 @@ if (!nodeInterop && obj && obj.__esModule) { | ||
} | ||
/** | ||
@@ -79,8 +70,8 @@ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
*/ | ||
const DTRACE = Object.keys(globalThis).filter(key => key.startsWith('DTRACE')); | ||
function installCommonGlobals(globalObject, globals) { | ||
globalObject.process = (0, _createProcessObject.default)(); | ||
const symbol = globalObject.Symbol; // Keep a reference to some globals that Jest needs | ||
const symbol = globalObject.Symbol; | ||
// Keep a reference to some globals that Jest needs | ||
Object.defineProperties(globalObject, { | ||
@@ -117,4 +108,5 @@ [symbol.for('jest-native-promise')]: { | ||
} | ||
}); // Forward some APIs. | ||
}); | ||
// Forward some APIs. | ||
DTRACE.forEach(dtrace => { | ||
@@ -121,0 +113,0 @@ // @ts-expect-error: no index |
@@ -7,3 +7,2 @@ 'use strict'; | ||
exports.default = interopRequireDefault; | ||
/** | ||
@@ -15,2 +14,3 @@ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
*/ | ||
// copied from https://github.com/babel/babel/blob/56044c7851d583d498f919e9546caddf8f80a72f/packages/babel-helpers/src/helpers.js#L558-L562 | ||
@@ -17,0 +17,0 @@ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types |
@@ -7,13 +7,9 @@ 'use strict'; | ||
exports.default = void 0; | ||
function _ciInfo() { | ||
const data = require('ci-info'); | ||
_ciInfo = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
/** | ||
@@ -24,6 +20,4 @@ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
var _default = | ||
*/ var _default = | ||
!!process.stdout.isTTY && process.env.TERM !== 'dumb' && !_ciInfo().isCI; | ||
exports.default = _default; |
@@ -7,3 +7,2 @@ 'use strict'; | ||
exports.default = isPromise; | ||
/** | ||
@@ -15,2 +14,3 @@ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
*/ | ||
function isPromise(candidate) { | ||
@@ -17,0 +17,0 @@ return ( |
@@ -7,3 +7,2 @@ 'use strict'; | ||
exports.default = pluralize; | ||
/** | ||
@@ -15,4 +14,5 @@ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
*/ | ||
function pluralize(word, count) { | ||
return `${count} ${word}${count === 1 ? '' : 's'}`; | ||
} |
@@ -8,21 +8,14 @@ 'use strict'; | ||
exports.remove = remove; | ||
function _chalk() { | ||
const data = _interopRequireDefault(require('chalk')); | ||
_chalk = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
var _clearLine = _interopRequireDefault(require('./clearLine')); | ||
var _isInteractive = _interopRequireDefault(require('./isInteractive')); | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
/** | ||
@@ -34,2 +27,3 @@ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
*/ | ||
function print(stream) { | ||
@@ -42,3 +36,2 @@ if (_isInteractive.default) { | ||
} | ||
function remove(stream) { | ||
@@ -45,0 +38,0 @@ if (_isInteractive.default) { |
@@ -7,3 +7,2 @@ 'use strict'; | ||
exports.default = replacePathSepForGlob; | ||
/** | ||
@@ -15,4 +14,5 @@ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
*/ | ||
function replacePathSepForGlob(path) { | ||
return path.replace(/\\(?![{}()+?.^$])/g, '/'); | ||
} |
@@ -7,31 +7,22 @@ 'use strict'; | ||
exports.default = requireOrImportModule; | ||
function _path() { | ||
const data = require('path'); | ||
_path = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _url() { | ||
const data = require('url'); | ||
_url = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
var _interopRequireDefault = _interopRequireDefault2( | ||
require('./interopRequireDefault') | ||
); | ||
function _interopRequireDefault2(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
/** | ||
@@ -43,2 +34,3 @@ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
*/ | ||
async function requireOrImportModule( | ||
@@ -53,10 +45,7 @@ filePath, | ||
} | ||
try { | ||
const requiredModule = require(filePath); | ||
if (!applyInteropRequireDefault) { | ||
return requiredModule; | ||
} | ||
return (0, _interopRequireDefault.default)(requiredModule).default; | ||
@@ -66,10 +55,9 @@ } catch (error) { | ||
try { | ||
const moduleUrl = (0, _url().pathToFileURL)(filePath); // node `import()` supports URL, but TypeScript doesn't know that | ||
const moduleUrl = (0, _url().pathToFileURL)(filePath); | ||
// node `import()` supports URL, but TypeScript doesn't know that | ||
const importedModule = await import(moduleUrl.href); | ||
if (!applyInteropRequireDefault) { | ||
return importedModule; | ||
} | ||
if (!importedModule.default) { | ||
@@ -80,3 +68,2 @@ throw new Error( | ||
} | ||
return importedModule.default; | ||
@@ -89,3 +76,2 @@ } catch (innerError) { | ||
} | ||
throw innerError; | ||
@@ -92,0 +78,0 @@ } |
@@ -7,3 +7,2 @@ 'use strict'; | ||
exports.default = setGlobal; | ||
/** | ||
@@ -15,2 +14,3 @@ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
*/ | ||
function setGlobal(globalToMutate, key, value) { | ||
@@ -17,0 +17,0 @@ // @ts-expect-error: no index |
@@ -7,3 +7,2 @@ 'use strict'; | ||
exports.ICONS = exports.CLEAR = exports.ARROW = void 0; | ||
/** | ||
@@ -15,2 +14,3 @@ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
*/ | ||
const isWindows = process.platform === 'win32'; | ||
@@ -17,0 +17,0 @@ const ARROW = ' \u203A '; |
@@ -7,3 +7,2 @@ 'use strict'; | ||
exports.default = testPathPatternToRegExp; | ||
/** | ||
@@ -15,2 +14,3 @@ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
*/ | ||
// Because we serialize/deserialize globalConfig when we spawn workers, | ||
@@ -17,0 +17,0 @@ // we can't pass regular expression. Using this shared function on both sides |
@@ -7,13 +7,9 @@ 'use strict'; | ||
exports.default = tryRealpath; | ||
function _gracefulFs() { | ||
const data = require('graceful-fs'); | ||
_gracefulFs = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
/** | ||
@@ -25,2 +21,3 @@ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
*/ | ||
function tryRealpath(path) { | ||
@@ -34,4 +31,3 @@ try { | ||
} | ||
return path; | ||
} |
{ | ||
"name": "jest-util", | ||
"version": "29.1.2", | ||
"version": "29.2.0", | ||
"repository": { | ||
@@ -20,3 +20,3 @@ "type": "git", | ||
"dependencies": { | ||
"@jest/types": "^29.1.2", | ||
"@jest/types": "^29.2.0", | ||
"@types/node": "*", | ||
@@ -38,3 +38,3 @@ "chalk": "^4.0.0", | ||
}, | ||
"gitHead": "3c31dd619e8c022cde53f40fa12ea2a67f4752ce" | ||
"gitHead": "ee5b37a4f4433afcfffb0356cea47739d8092287" | ||
} |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
1105
35627
5
+ Added@types/node@20.12.12(transitive)
- Removed@types/node@20.12.11(transitive)
Updated@jest/types@^29.2.0