orionsoft-react-scripts
Version:
Orionsoft Configuration and scripts for Create React App.
49 lines (35 loc) • 1.17 kB
Markdown
by Jest to check which files have changed since you
last committed in git or hg.
```sh
$ npm install --save jest-changed-files
```
Get the root of the mercurial repository containing `cwd` or return `null` if
`cwd` is not inside a mercurial repository.
Get the root of the git repository containing `cwd` or return `null` if
`cwd` is not inside a git repository.
Get the list of files in a git/mecurial repository that have changed since the
last commit.
```javascript
import {git, hg} from 'jest-changed-files';
function changedFiles(cwd) {
return Promise.all([
git.isGitRepository(cwd),
hg.isHGRepository(cwd),
]).then(([gitRoot, hgRoot]) => {
if (gitRoot !== null) {
return git.findChangedFiles(gitRoot);
} else if (hgRoot !== null) {
return hg.findChangedFiles(hgRoot);
} else {
throw new Error('Not in a git or hg repo');
}
});
}
```
A module used internally