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

Function getChangedFilesForRoots

packages/jest-changed-files/src/index.ts:26–60  ·  view source on GitHub ↗
(
  roots: Array<string>,
  options: Options,
)

Source from the content-addressed store, hash-verified

24const findSlRoot = (dir: string) => mutex(() => sl.getRoot(dir));
25
26export const getChangedFilesForRoots = async (
27 roots: Array<string>,
28 options: Options,
29): ChangedFilesPromise => {
30 const repos = await findRepos(roots);
31
32 const changedFilesOptions = {includePaths: roots, ...options};
33
34 const gitPromises = Array.from(repos.git, repo =>
35 git.findChangedFiles(repo, changedFilesOptions),
36 );
37
38 const hgPromises = Array.from(repos.hg, repo =>
39 hg.findChangedFiles(repo, changedFilesOptions),
40 );
41
42 const slPromises = Array.from(repos.sl, repo =>
43 sl.findChangedFiles(repo, changedFilesOptions),
44 );
45
46 const allVcs = await Promise.all([
47 ...gitPromises,
48 ...hgPromises,
49 ...slPromises,
50 ]);
51 const changedFiles = allVcs.reduce((allFiles, changedFilesInTheRepo) => {
52 for (const file of changedFilesInTheRepo) {
53 allFiles.add(file);
54 }
55
56 return allFiles;
57 }, new Set<string>());
58
59 return {changedFiles, repos};
60};
61
62export const findRepos = async (roots: Array<string>): Promise<Repos> => {
63 const [gitRepos, hgRepos, slRepos] = await Promise.all([

Callers 2

getChangedFilesPromiseFunction · 0.90

Calls 2

findReposFunction · 0.85
addMethod · 0.45

Tested by

no test coverage detected