Skip to content

Commit a0e067a

Browse files
authored
changed-files: simplify find repos (#14503)
1 parent 856d6ab commit a0e067a

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

Diff for: packages/jest-changed-files/src/index.ts

+6-17
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ import {isNonNullable} from 'jest-util';
1111
import git from './git';
1212
import hg from './hg';
1313
import sl from './sl';
14-
import type {ChangedFilesPromise, Options, Repos, SCMAdapter} from './types';
15-
16-
type RootPromise = ReturnType<SCMAdapter['getRoot']>;
14+
import type {ChangedFilesPromise, Options, Repos} from './types';
1715

1816
export type {ChangedFiles, ChangedFilesPromise} from './types';
1917

@@ -59,20 +57,11 @@ export const getChangedFilesForRoots = async (
5957
};
6058

6159
export const findRepos = async (roots: Array<string>): Promise<Repos> => {
62-
const gitRepos = await Promise.all(
63-
roots.reduce<Array<RootPromise>>(
64-
(promises, root) => promises.concat(findGitRoot(root)),
65-
[],
66-
),
67-
);
68-
const hgRepos = await Promise.all(
69-
roots.reduce<Array<RootPromise>>(
70-
(promises, root) => promises.concat(findHgRoot(root)),
71-
[],
72-
),
73-
);
74-
75-
const slRepos = await Promise.all(roots.map(findSlRoot));
60+
const [gitRepos, hgRepos, slRepos] = await Promise.all([
61+
Promise.all(roots.map(findGitRoot)),
62+
Promise.all(roots.map(findHgRoot)),
63+
Promise.all(roots.map(findSlRoot)),
64+
]);
7665

7766
return {
7867
git: new Set(gitRepos.filter(isNonNullable)),

0 commit comments

Comments
 (0)