Skip to content

Commit

Permalink
#77: adds more instructions for .check_ignore()
Browse files Browse the repository at this point in the history
  • Loading branch information
kaelzhang committed Dec 18, 2024
1 parent 2033cb0 commit 8d9c3e5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 46 deletions.
53 changes: 28 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,31 +149,17 @@ ignore()

`pattern` could also be an `ignore` instance, so that we could easily inherit the rules of another `Ignore` instance.

## <strike>.addIgnoreFile(path)</strike>
## .ignores(pathname: [Pathname](#pathname-conventions)): boolean

REMOVED in `3.x` for now.
> new in 3.2.0
To upgrade `[email protected]` up to `3.x`, use
Returns `Boolean` whether `pathname` should be ignored.

```js
import fs from 'fs'

if (fs.existsSync(filename)) {
ignore().add(fs.readFileSync(filename).toString())
}
```

instead.

## .filter(paths: Array&lt;Pathname&gt;): Array&lt;Pathname&gt;

```ts
type Pathname = string
ig.ignores('.abc/a.js') // true
```

Filters the given array of pathnames, and returns the filtered array.
- **paths** `Array.<Pathname>` The array of `pathname`s to be filtered.
Please **PAY ATTENTION** that `.ignores()` does not equivalent to `git check-ignore` although in most cases they return equivalent results. However, for the purposes of imitating the behavior of `git check-ignore`, please use `.check_ignore()` instead.

### `Pathname` Conventions:

Expand Down Expand Up @@ -266,16 +252,17 @@ glob('**', {
})
```

## .ignores(pathname: Pathname): boolean

> new in 3.2.0
Returns `Boolean` whether `pathname` should be ignored.
## .filter(paths: Array&lt;Pathname&gt;): Array&lt;Pathname&gt;

```js
ig.ignores('.abc/a.js') // true
```ts
type Pathname = string
```
Filters the given array of pathnames, and returns the filtered array.
- **paths** `Array.<Pathname>` The array of `pathname`s to be filtered.
## .createFilter()
Creates a filter function which could filter an array of paths with `Array.prototype.filter`.
Expand Down Expand Up @@ -310,6 +297,22 @@ import {isPathValid} from 'ignore'
isPathValid('./foo') // false
```

## <strike>.addIgnoreFile(path)</strike>

REMOVED in `3.x` for now.

To upgrade `[email protected]` up to `3.x`, use

```js
import fs from 'fs'

if (fs.existsSync(filename)) {
ignore().add(fs.readFileSync(filename).toString())
}
```

instead.

## ignore(options)

### `options.ignorecase` since 4.0.0
Expand Down
21 changes: 0 additions & 21 deletions test/fixtures/cases.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,6 @@ const cases = [
// }
// ],
/////////////////////////////////////////////////////////////////////
[
'#77: ignore the content of directory c, but not the directory c itself',
[
'c/',
'!c',
'c/*'
],
{
'c': 0,
'c/': 1
}
],
[
'#77: issue for "directory ending with / not always correctly ignored"',
[
'c/*'
],
{
'c/': 1
}
],
[
'#108: gitignore rules with BOM',
[
Expand Down

0 comments on commit 8d9c3e5

Please sign in to comment.