( roots: Array<string>, options: Options, )
| 24 | const findSlRoot = (dir: string) => mutex(() => sl.getRoot(dir)); |
| 25 | |
| 26 | export 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 | |
| 62 | export const findRepos = async (roots: Array<string>): Promise<Repos> => { |
| 63 | const [gitRepos, hgRepos, slRepos] = await Promise.all([ |
no test coverage detected