JSPM

jest-changed-files

16.1.0-alpha.691b0e22
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 36302663
  • Score
    100M100P100Q244446F
  • License BSD-3-Clause

Package Exports

  • jest-changed-files

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (jest-changed-files) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

jest-changed-files

A module used internally by Jest to check which files have changed since you last committed in git or hg.

Install

$ npm install --save jest-changed-files

API

hg.isHGRepository(cwd: string): Promise<?string>

Get the root of the mercurial repository containing cwd or return null if cwd is not inside a mercurial repository.

git.isGitRepository(cwd: string): Promise<?string>

Get the root of the git repository containing cwd or return null if cwd is not inside a git repository.

hg.findChangedFiles / git.findChangedFiles (root: string): Promise<Array<string>>

Get the list of files in a git/mecurial repository that have changed since the last commit.

Usage

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');
    }
  });
}