Skip to content

isPathIgnored

Test if the ignore rules apply to a given path.

This function checks the ignore rules to see if they would apply to the given file. This indicates if the file would be ignored regardless of whether the file is already in the index or committed to the repository.

Signature

ts
class Repository {
  isPathIgnored(path: string): boolean;
}

Parameters

  • pathrequired · string

    The path to check.

Returns

  • boolean

    - True if the path is ignored, false otherwise.

Examples

ts
import { openRepository } from 'es-git';

const repo = await openRepository('./path/to/repo');
const isIgnored = repo.isPathIgnored("node_modules/some-package");
console.log(`Path is ${isIgnored ? "ignored" : "not ignored"}`);

Released under the MIT License.