@@ -11,38 +11,50 @@ $ npm install --save jest-changed-files
1111
1212## API
1313
14- ### ` hg.isHGRepository(cwd: string): Promise<?string >`
14+ ### ` getChangedFilesForRoots(roots: <Array< string>>, options: ?object ): Promise<?object >`
1515
16- Get the root of the mercurial repository containing ` cwd ` or return ` null ` if
17- ` cwd ` is not inside a mercurial repository.
16+ Get the list of files and repos that have changed since the last commit.
1817
19- ### ` git.isGitRepository(cwd: string): Promise<?string> `
18+ #### Parameters
19+ roots: Array of string paths gathered from [ jest roots] ( https://facebook.github.io/jest/docs/configuration.html#roots-array-string ) .
2020
21- Get the root of the git repository containing ` cwd ` or return ` null ` if
22- ` cwd ` is not inside a git repository.
21+ options: Object literal with keys
22+ * lastCommit: boolean
23+ * withAncestor: boolean
2324
24- ### ` hg.findChangedFiles / git.findChangedFiles (root: string): Promise<Array<string>> `
25+ ### findRepos(roots: <Array< string >> ): Promise<?object>
2526
26- Get the list of files in a git/mecurial repository that have changed since the
27- last commit.
27+ Get a set of git and hg repositories.
28+ #### Parameters
29+ roots: Array of string paths gathered from [ jest roots] ( https://facebook.github.io/jest/docs/configuration.html#roots-array-string ) .
2830
2931## Usage
3032
3133``` javascript
32- import {git , hg } from ' jest-changed-files' ;
33-
34- function changedFiles (cwd ) {
35- return Promise .all ([
36- git .isGitRepository (cwd),
37- hg .isHGRepository (cwd),
38- ]).then (([gitRoot , hgRoot ]) => {
39- if (gitRoot !== null ) {
40- return git .findChangedFiles (gitRoot);
41- } else if (hgRoot !== null ) {
42- return hg .findChangedFiles (hgRoot);
43- } else {
44- throw new Error (' Not in a git or hg repo' );
45- }
46- });
47- }
34+ import {getChangedFilesForRoots } from ' jest-changed-files' ;
35+
36+ getChangedFilesForRoots ([' /path/to/test' ], {
37+ lastCommit: true ,
38+ withAncestor: true ,
39+ }).then ((files ) => {
40+ /*
41+ {
42+ repos: [],
43+ changedFiles: []
44+ }
45+ */
46+ });
47+ ```
48+
49+ ``` javascript
50+ import {findRepos } from ' jest-changed-files' ;
51+
52+ findRepos ([' /path/to/test' ]).then ((repos ) => {
53+ /*
54+ {
55+ git: Set<Path>,
56+ hg: Set<Path>
57+ }
58+ */
59+ });
4860```
0 commit comments