cspell-gitignore
Gitignore Glob matcher for cspell
Last updated 2 years ago by jason-dent .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install cspell-gitignore 
SYNC missed versions from official npm registry.

cspell-gitignore

A library to assist reading and filtering out files matching glob patterns found in .gitignore files.

Install

npm install -S cspell-gitignore

Usage

import { GitIgnore, findRepoRoot } from 'cspell-gitignore';

// ...

const cwd = process.cwd();
const root = (await findRepoRoot(cwd)) || cwd;
const gitIgnore = new GitIgnore([root]);

const allFiles = glob('**');

const files = await gitIgnore.filterOutIgnored(allFiles);

Logic

  • For each file, search for the .gitignore files in the directory hierarchy.
  • Ignore any files that match the globs found in the .gitignore files.

The .gitignore globs are evaluated from highest to lowest, matching the git behavior.

To prevent searching higher in the directory hierarchy, specify roots:

const gitIgnore = new GitIgnore([process.cwd()]);

cspell-gitignore CLI

cspell-gitignore provides a simple cli for debugging .gitignore issues.

In most cases it should provide the same output as git check-ignore.

Usage

Usage cspell-gitignore [options] <files>

Check files against .gitignore
Compare against git check-ignore -v -n <files>

Options:
  -r, --root   Add a root to prevent searching for .gitignore files above the root if the file is under the root.
               This option can be used multiple times to add multiple roots. The default root is the current
               repository root determined by the `.git` directory.

Example:
  cspell-gitignore README.md
  cspell-gitignore -r . node_modules

Example:

$ cspell-gitignore -r . node_modules
.gitignore:58:node_modules/       node_modules

Current Tags

  • 5.21.2                                ...           cspell5 (2 years ago)
  • 5.21.2-alpha.0                                ...           cspell5-next (2 years ago)
  • 8.11.0                                ...           latest (4 months ago)
  • 8.9.0-alpha.0                                ...           next (5 months ago)

182 Versions

  • 8.11.0                                ...           4 months ago
  • 8.10.4                                ...           4 months ago
  • 8.10.2                                ...           4 months ago
  • 8.10.1                                ...           4 months ago
  • 8.10.0                                ...           4 months ago
  • 8.9.1                                ...           5 months ago
  • 8.9.0                                ...           5 months ago
  • 8.9.0-alpha.0                                ...           5 months ago
  • 8.8.4                                ...           5 months ago
  • 8.8.3                                ...           6 months ago
  • 8.8.2                                ...           6 months ago
  • 8.8.1                                ...           6 months ago
  • 8.8.0                                ...           6 months ago
  • 8.7.0                                ...           7 months ago
  • 8.6.1                                ...           8 months ago
  • 8.6.0                                ...           8 months ago
  • 8.5.0                                ...           8 months ago
  • 8.4.1                                ...           9 months ago
  • 8.4.0                                ...           9 months ago
  • 8.3.2                                ...           10 months ago
  • 8.3.1                                ...           10 months ago
  • 8.3.0                                ...           a year ago
  • 8.2.4                                ...           a year ago
  • 8.2.3                                ...           a year ago
  • 8.2.1                                ...           a year ago
  • 8.2.0                                ...           a year ago
  • 8.1.3                                ...           a year ago
  • 8.1.2                                ...           a year ago
  • 8.1.1                                ...           a year ago
  • 8.1.0                                ...           a year ago
  • 8.0.0                                ...           a year ago
  • 7.3.9                                ...           a year ago
  • 7.3.8                                ...           a year ago
  • 7.3.7                                ...           a year ago
  • 7.3.6                                ...           a year ago
  • 7.3.5                                ...           a year ago
  • 7.3.4                                ...           a year ago
  • 7.3.3                                ...           a year ago
  • 7.3.2                                ...           a year ago
  • 7.3.1                                ...           a year ago
  • 7.3.0                                ...           a year ago
  • 7.2.0                                ...           a year ago
  • 7.1.1                                ...           a year ago
  • 7.0.2                                ...           a year ago
  • 7.0.1                                ...           a year ago
  • 7.0.0                                ...           a year ago
  • 7.0.1-alpha.9                                ...           a year ago
  • 6.31.3                                ...           a year ago
  • 7.0.1-alpha.8                                ...           a year ago
  • 7.0.1-alpha.7                                ...           a year ago
  • 6.31.2                                ...           a year ago
  • 7.0.1-alpha.6                                ...           a year ago
  • 7.0.1-alpha.5                                ...           a year ago
  • 7.0.1-alpha.4                                ...           a year ago
  • 7.0.1-alpha.3                                ...           a year ago
  • 7.0.1-alpha.2                                ...           a year ago
  • 7.0.1-alpha.1                                ...           a year ago
  • 7.0.1-alpha.0                                ...           a year ago
  • 7.0.0-alpha.2                                ...           2 years ago
  • 7.0.0-alpha.1                                ...           2 years ago
  • 6.31.1                                ...           2 years ago
  • 6.31.0                                ...           2 years ago
  • 6.30.2                                ...           2 years ago
  • 6.30.1                                ...           2 years ago
  • 6.30.0                                ...           2 years ago
  • 6.29.3                                ...           2 years ago
  • 6.29.2                                ...           2 years ago
  • 6.29.1                                ...           2 years ago
  • 6.29.0                                ...           2 years ago
  • 6.28.0                                ...           2 years ago
  • 6.27.0                                ...           2 years ago
  • 6.26.3                                ...           2 years ago
  • 6.26.2                                ...           2 years ago
  • 6.26.1                                ...           2 years ago
  • 6.26.0                                ...           2 years ago
  • 6.25.0                                ...           2 years ago
  • 6.24.0                                ...           2 years ago
  • 6.23.1                                ...           2 years ago
  • 6.23.0                                ...           2 years ago
  • 6.22.0                                ...           2 years ago
  • 6.21.0                                ...           2 years ago
  • 6.20.1                                ...           2 years ago
  • 6.20.0                                ...           2 years ago
  • 6.19.2                                ...           2 years ago
  • 6.19.1                                ...           2 years ago
  • 6.19.0                                ...           2 years ago
  • 6.18.1                                ...           2 years ago
  • 6.18.0                                ...           2 years ago
  • 6.17.0                                ...           2 years ago
  • 6.16.0                                ...           2 years ago
  • 6.15.1                                ...           2 years ago
  • 6.15.0                                ...           2 years ago
  • 6.14.3                                ...           2 years ago
  • 6.14.2                                ...           2 years ago
  • 6.14.1                                ...           2 years ago
  • 6.14.0                                ...           2 years ago
  • 6.13.3                                ...           2 years ago
  • 6.13.2                                ...           2 years ago
  • 6.13.1                                ...           2 years ago
  • 6.13.0                                ...           2 years ago
  • 6.12.0                                ...           2 years ago
  • 6.11.1                                ...           2 years ago
  • 6.11.0                                ...           2 years ago
  • 6.10.1                                ...           2 years ago
  • 6.10.0                                ...           2 years ago
  • 6.9.1                                ...           2 years ago
  • 6.9.0                                ...           2 years ago
  • 6.8.2                                ...           2 years ago
  • 6.8.1                                ...           2 years ago
  • 6.8.0                                ...           2 years ago
  • 6.7.0                                ...           2 years ago
  • 6.6.1                                ...           2 years ago
  • 6.6.1-alpha.9                                ...           2 years ago
  • 6.6.1-alpha.2                                ...           2 years ago
  • 6.6.1-alpha.1                                ...           2 years ago
  • 6.6.1-alpha.0                                ...           2 years ago
  • 6.6.0                                ...           2 years ago
  • 6.5.0                                ...           2 years ago
  • 6.4.2                                ...           2 years ago
  • 6.4.1                                ...           2 years ago
  • 6.4.0                                ...           2 years ago
  • 6.4.0-alpha.0                                ...           2 years ago
  • 6.3.0                                ...           2 years ago
  • 6.2.4-alpha.0                                ...           2 years ago
  • 6.2.3                                ...           2 years ago
  • 6.2.2                                ...           2 years ago
  • 6.2.1                                ...           2 years ago
  • 6.2.0                                ...           2 years ago
  • 6.2.0-alpha.1                                ...           2 years ago
  • 6.2.0-alpha.0                                ...           2 years ago
  • 6.1.3                                ...           2 years ago
  • 6.1.3-alpha.1                                ...           2 years ago
  • 6.1.3-alpha.0                                ...           2 years ago
  • 6.1.2                                ...           2 years ago
  • 6.1.1                                ...           2 years ago
  • 6.1.0                                ...           2 years ago
  • 6.1.0-alpha.0                                ...           2 years ago
  • 5.21.2                                ...           2 years ago
  • 6.0.0                                ...           2 years ago
  • 5.21.2-alpha.0                                ...           2 years ago
  • 6.0.0-alpha.0                                ...           2 years ago
  • 5.21.1                                ...           2 years ago
  • 5.21.0                                ...           2 years ago
  • 5.20.0                                ...           3 years ago
  • 5.19.7                                ...           3 years ago
  • 5.19.6                                ...           3 years ago
  • 5.19.5                                ...           3 years ago
  • 5.19.4                                ...           3 years ago
  • 5.19.3                                ...           3 years ago
  • 5.19.2                                ...           3 years ago
  • 5.19.1                                ...           3 years ago
  • 5.19.0                                ...           3 years ago
  • 5.18.5                                ...           3 years ago
  • 5.18.4                                ...           3 years ago
  • 5.18.3                                ...           3 years ago
  • 5.18.2                                ...           3 years ago
  • 5.18.1                                ...           3 years ago
  • 5.18.0                                ...           3 years ago
  • 5.18.0-alpha.0                                ...           3 years ago
  • 5.17.0                                ...           3 years ago
  • 5.17.0-alpha.0                                ...           3 years ago
  • 5.16.0                                ...           3 years ago
  • 5.15.3                                ...           3 years ago
  • 5.15.2                                ...           3 years ago
  • 5.15.1                                ...           3 years ago
  • 5.15.0                                ...           3 years ago
  • 5.14.0                                ...           3 years ago
  • 5.14.0-alpha.0                                ...           3 years ago
  • 5.13.4                                ...           3 years ago
  • 5.13.3                                ...           3 years ago
  • 5.13.2                                ...           3 years ago
  • 5.13.1                                ...           3 years ago
  • 5.13.0                                ...           3 years ago
  • 5.12.6                                ...           3 years ago
  • 5.12.5                                ...           3 years ago
  • 5.12.4                                ...           3 years ago
  • 5.12.3                                ...           3 years ago
  • 5.12.2                                ...           3 years ago
  • 5.12.1                                ...           3 years ago
  • 5.12.0                                ...           3 years ago
  • 5.12.0-alpha.0                                ...           3 years ago
  • 5.11.1                                ...           3 years ago
Maintainers (1)
Downloads
Total 2
Today 1
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (0)
None
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE