UNPKG

1.23 kBMarkdownView Raw
1# jest-changed-files
2
3A module used internally by Jest to check which files have changed since you last committed in git or hg.
4
5## Install
6
7```sh
8$ npm install --save jest-changed-files
9```
10
11## API
12
13### `getChangedFilesForRoots(roots: <Array<string>>, options: ?object): Promise<?object>`
14
15Get the list of files and repos that have changed since the last commit.
16
17#### Parameters
18
19roots: Array of string paths gathered from [jest roots](https://jestjs.io/docs/configuration#roots-arraystring).
20
21options: Object literal with keys
22
23- lastCommit: boolean
24- withAncestor: boolean
25
26### findRepos(roots: <Array<string>>): Promise<?object>
27
28Get a set of git and hg repositories.
29
30#### Parameters
31
32roots: Array of string paths gathered from [jest roots](https://jestjs.io/docs/configuration#roots-arraystring).
33
34## Usage
35
36```javascript
37import {getChangedFilesForRoots} from 'jest-changed-files';
38
39getChangedFilesForRoots(['/path/to/test'], {
40 lastCommit: true,
41 withAncestor: true,
42}).then(files => {
43 /*
44 {
45 repos: [],
46 changedFiles: []
47 }
48 */
49});
50```
51
52```javascript
53import {findRepos} from 'jest-changed-files';
54
55findRepos(['/path/to/test']).then(repos => {
56 /*
57 {
58 git: Set<Path>,
59 hg: Set<Path>
60 }
61 */
62});
63```