-
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Update gitignore README and normalize roots (#1832)
* fix: Update `cspell-gitignore` README * fix: normalize `gitignoreRoot`s
- Loading branch information
Showing
4 changed files
with
93 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,36 @@ | ||
# `cspell-glob` | ||
# `cspell-gitignore` | ||
|
||
A simple library for checking filenames against a set of glob rules. It attempts to emulate the `.gitignore` rules. | ||
A library to assist reading and filtering out files matching glob patterns found in `.gitignore` files. | ||
|
||
## Purpose | ||
## Install | ||
|
||
The purpose behind this library is a bit different than the other glob matchers. | ||
The goal here is to see if a file name matches a glob, not to find files that match globs. | ||
This library doesn't do any file i/o. It uses [micromatch](https://github.com/micromatch/micromatch#readme) under the hood for the actual matching. | ||
```sh | ||
npm install -S cspell-gitignore | ||
``` | ||
|
||
## Usage | ||
|
||
```ts | ||
import { GitIgnore } from 'cspell-gitignore'; | ||
|
||
// ... | ||
|
||
const gitIgnore = new GitIgnore(); | ||
|
||
const allFiles = glob('**'); | ||
|
||
const files = await gitIgnore.filterOutIgnored(allFiles); | ||
``` | ||
const cspellGlob = require('cspell-glob'); | ||
|
||
// TODO: DEMONSTRATE API | ||
## 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: | ||
|
||
```ts | ||
const gitIgnore = new GitIgnore([process.cwd()]); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters