MCPcopy
hub / github.com/web-infra-dev/rsbuild / findFile

Function findFile

e2e/helper/utils.ts:275–291  ·  view source on GitHub ↗
(
  files: Record<string, string>,
  matcher: FileMatcher,
  options: FindFileOptions = {},
)

Source from the content-addressed store, hash-verified

273 * @throws {Error} When no matching file is found
274 */
275export const findFile = (
276 files: Record<string, string>,
277 matcher: FileMatcher,
278 options: FindFileOptions = {},
279): string => {
280 const { ignoreHash = true } = options;
281 const getComparable = (file: string) => (ignoreHash ? file.replace(HASH_PATTERN, '') : file);
282 const matcherFn = toMatcherFn(matcher);
283
284 for (const file of Object.keys(files)) {
285 if (matcherFn(getComparable(file))) {
286 return file;
287 }
288 }
289
290 throw new Error(`Unable to find file matching "${styleText('cyan', matcher.toString())}"`);
291};
292
293/**
294 * Get the content of the first matching file from a files map

Callers 15

index.test.tsFile · 0.90
index.test.tsFile · 0.90
index.test.tsFile · 0.90
index.test.tsFile · 0.90
index.test.tsFile · 0.90
index.test.tsFile · 0.90
index.test.tsFile · 0.90
index.test.tsFile · 0.90
index.test.tsFile · 0.90
index.test.tsFile · 0.90
index.test.tsFile · 0.90
index.test.tsFile · 0.90

Calls 2

toMatcherFnFunction · 0.85
getComparableFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…