MCPcopy Index your code
hub / github.com/code-pushup/cli / findNearestFile

Function findNearestFile

packages/utils/src/lib/file-system.ts:104–123  ·  view source on GitHub ↗
(
  fileNames: string[],
  cwd = process.cwd(),
)

Source from the content-addressed store, hash-verified

102}
103
104export async function findNearestFile(
105 fileNames: string[],
106 cwd = process.cwd(),
107): Promise<string | undefined> {
108 // eslint-disable-next-line functional/no-loop-statements
109 for (
110 // eslint-disable-next-line functional/no-let
111 let directory = cwd;
112 directory !== path.dirname(directory);
113 directory = path.dirname(directory)
114 ) {
115 // eslint-disable-next-line functional/no-loop-statements
116 for (const file of fileNames) {
117 if (await fileExists(path.join(directory, file))) {
118 return path.join(directory, file);
119 }
120 }
121 }
122 return undefined;
123}
124
125export function findLineNumberInText(
126 content: string,

Callers 2

Calls 1

fileExistsFunction · 0.85

Tested by

no test coverage detected