MCPcopy
hub / github.com/jestjs/jest / resolve

Function resolve

packages/jest-config/src/utils.ts:30–52  ·  view source on GitHub ↗
(
  resolver: string | null | undefined,
  {key, filePath, rootDir, optional}: ResolveOptions,
)

Source from the content-addressed store, hash-verified

28 new ValidationError(`${BULLET}Validation Error`, message, DOCUMENTATION_NOTE);
29
30export const resolve = (
31 resolver: string | null | undefined,
32 {key, filePath, rootDir, optional}: ResolveOptions,
33): string => {
34 const module = Resolver.findNodeModule(
35 replaceRootDirInPath(rootDir, filePath),
36 {
37 basedir: rootDir,
38 resolver: resolver || undefined,
39 },
40 );
41
42 if (!module && !optional) {
43 throw createValidationError(
44 ` Module ${chalk.bold(filePath)} in the ${chalk.bold(
45 key,
46 )} option was not found.
47 ${chalk.bold('<rootDir>')} is: ${rootDir}`,
48 );
49 }
50 /// can cast as string since nulls will be thrown
51 return module!;
52};
53
54export const escapeGlobCharacters = (path: string): string =>
55 path.replaceAll(/([!()*?[\\\]{}])/g, '\\$1');

Callers 15

normalizeFunction · 0.90
doneFunction · 0.50
callAsyncCircusFnFunction · 0.50
writeFunction · 0.50
runMethod · 0.50
runMethod · 0.50
runMethod · 0.50
runMethod · 0.50
countToFinishFunction · 0.50
testWorkerFarmFunction · 0.50

Calls 3

findNodeModuleMethod · 0.80
replaceRootDirInPathFunction · 0.70
createValidationErrorFunction · 0.70

Tested by 4

writeFunction · 0.40
waitForChangeFunction · 0.40
fooPromiseWorksFunction · 0.40
fooPromiseWorksFunction · 0.40