Skip to content

Commit bc4e324

Browse files
authored
Merge pull request #145 from kaelzhang/7.0.0
7.0.0
2 parents d88109f + 079e1b0 commit bc4e324

File tree

10 files changed

+466
-243
lines changed

10 files changed

+466
-243
lines changed

.eslintrc.js

+24-15
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,31 @@
11
// http://eslint.org/docs/user-guide/configuring
22

3+
const rules = {
4+
'no-underscore-dangle': ['error', {
5+
allowAfterThis: true,
6+
enforceInMethodNames: false,
7+
// node-ignore only
8+
allow: ['_rules', '_test']
9+
}],
10+
11+
'operator-linebreak': 0,
12+
13+
indent: ['error', 2, {
14+
MemberExpression: 0,
15+
16+
// Eslint bug
17+
ignoreComments: true
18+
}]
19+
}
20+
21+
if (process.platform === 'win32') {
22+
// Ignore linebreak-style on Windows, due to a bug of eslint
23+
rules['linebreak-style'] = 0
24+
}
25+
326
module.exports = {
427
// Uses `require.resolve` to support npm linked eslint-config
528
extends: require.resolve('eslint-config-ostai'),
629
root: true,
7-
rules: {
8-
'no-underscore-dangle': ['error', {
9-
allowAfterThis: true,
10-
enforceInMethodNames: false,
11-
// node-ignore only
12-
allow: ['_rules', '_test']
13-
}],
14-
15-
indent: ['error', 2, {
16-
MemberExpression: 0,
17-
18-
// Eslint bug
19-
ignoreComments: true
20-
}]
21-
}
30+
rules
2231
}

.github/workflows/nodejs.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ on: [push]
44

55
jobs:
66
build:
7-
8-
runs-on: ubuntu-latest
9-
107
strategy:
118
matrix:
9+
os: [ubuntu-latest, windows-latest, macos-latest]
1210
node-version: [20.x]
1311

12+
runs-on: ${{ matrix.os }}
13+
1414
steps:
1515
- uses: actions/checkout@v1
1616
- name: Use Node.js ${{ matrix.node-version }}

README.md

+63-40
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,15 @@
1-
<table><thead>
2-
<tr>
3-
<th>Linux</th>
4-
<th>OS X</th>
5-
<th>Windows</th>
6-
<th>Coverage</th>
7-
<th>Downloads</th>
8-
</tr>
9-
</thead><tbody><tr>
10-
<td colspan="2" align="center">
11-
<a href="https://github.com/kaelzhang/node-ignore/actions/workflows/nodejs.yml">
12-
<img
13-
src="https://github.com/kaelzhang/node-ignore/actions/workflows/nodejs.yml/badge.svg"
14-
alt="Build Status" /></a>
15-
</td>
16-
<td align="center">
17-
<a href="https://ci.appveyor.com/project/kaelzhang/node-ignore">
18-
<img
19-
src="https://ci.appveyor.com/api/projects/status/github/kaelzhang/node-ignore?branch=master&svg=true"
20-
alt="Windows Build Status" /></a>
21-
</td>
22-
<td align="center">
23-
<a href="https://codecov.io/gh/kaelzhang/node-ignore">
24-
<img
25-
src="https://codecov.io/gh/kaelzhang/node-ignore/branch/master/graph/badge.svg"
26-
alt="Coverage Status" /></a>
27-
</td>
28-
<td align="center">
29-
<a href="https://www.npmjs.org/package/ignore">
30-
<img
31-
src="http://img.shields.io/npm/dm/ignore.svg"
32-
alt="npm module downloads per month" /></a>
33-
</td>
34-
</tr></tbody></table>
1+
| Linux / MacOS / Windows | Coverage | Downloads |
2+
| ----------------------- | -------- | --------- |
3+
| [![build][bb]][bl] | [![coverage][cb]][cl] | [![downloads][db]][dl] |
4+
5+
[bb]: https://github.com/kaelzhang/node-ignore/actions/workflows/nodejs.yml/badge.svg
6+
[bl]: https://github.com/kaelzhang/node-ignore/actions/workflows/nodejs.yml
7+
8+
[cb]: https://codecov.io/gh/kaelzhang/node-ignore/branch/master/graph/badge.svg
9+
[cl]: https://codecov.io/gh/kaelzhang/node-ignore
10+
11+
[db]: http://img.shields.io/npm/dm/ignore.svg
12+
[dl]: https://www.npmjs.org/package/ignore
3513

3614
# ignore
3715

@@ -124,9 +102,11 @@ ig.filter(['.abc\\a.js', '.abc\\d\\e.js'])
124102

125103
## .add(pattern: string | Ignore): this
126104
## .add(patterns: Array<string | Ignore>): this
105+
## .add({pattern: string, mark?: string}): this since 7.0.0
127106

128-
- **pattern** `String | Ignore` An ignore pattern string, or the `Ignore` instance
129-
- **patterns** `Array<String | Ignore>` Array of ignore patterns.
107+
- **pattern** `string | Ignore` An ignore pattern string, or the `Ignore` instance
108+
- **patterns** `Array<string | Ignore>` Array of ignore patterns.
109+
- **mark?** `string` Pattern mark, which is used to associate the pattern with a certain marker, such as the line no of the `.gitignore` file. Actually it could be an arbitrary string and is optional.
130110

131111
Adds a rule or several rules to the current manager.
132112

@@ -218,7 +198,11 @@ Then the `paths` might be like this:
218198

219199
#### 2. filenames and dirnames
220200

221-
`node-ignore` does NO `fs.stat` during path matching, so for the example below:
201+
`node-ignore` does NO `fs.stat` during path matching, so `node-ignore` treats
202+
- `foo` as a file
203+
- **`foo/` as a directory**
204+
205+
For the example below:
222206

223207
```js
224208
// First, we add a ignore pattern to ignore a directory
@@ -271,25 +255,64 @@ Creates a filter function which could filter an array of paths with `Array.proto
271255
272256
Returns `function(path)` the filter function.
273257
274-
## .test(pathname: Pathname) since 5.0.0
258+
## .test(pathname: Pathname): TestResult
259+
260+
> New in 5.0.0
275261
276262
Returns `TestResult`
277263
278264
```ts
265+
// Since 5.0.0
279266
interface TestResult {
280267
ignored: boolean
281268
// true if the `pathname` is finally unignored by some negative pattern
282269
unignored: boolean
270+
// The `IgnoreRule` which ignores the pathname
271+
rule?: IgnoreRule
272+
}
273+
274+
// Since 7.0.0
275+
interface IgnoreRule {
276+
// The original pattern
277+
pattern: string
278+
// Whether the pattern is a negative pattern
279+
negative: boolean
280+
// Which is used for other packages to build things upon `node-ignore`
281+
mark?: string
283282
}
284283
```
285284

286285
- `{ignored: true, unignored: false}`: the `pathname` is ignored
287286
- `{ignored: false, unignored: true}`: the `pathname` is unignored
288287
- `{ignored: false, unignored: false}`: the `pathname` is never matched by any ignore rules.
289288

290-
## .checkIgnore(pattern) since 6.1.0
289+
## .checkIgnore(target: string): TestResult
290+
291+
> new in 7.0.0
292+
293+
Debugs gitignore / exclude files, which is equivalent to `git check-ignore -v`. Usually this method is used for other packages to implement the function of `git check-ignore -v` upon `node-ignore`
294+
295+
- **target** `string` the target to test.
291296

292-
> new in 6.1.0
297+
Returns `TestResult`
298+
299+
```js
300+
ig.add({
301+
pattern: 'foo/*',
302+
mark: '60'
303+
})
304+
305+
const {
306+
ignored,
307+
rule
308+
} = checkIgnore('foo/')
309+
310+
if (ignored) {
311+
console.log(`.gitignore:${result}:${rule.mark}:${rule.pattern} foo/`)
312+
}
313+
314+
// .gitignore:60:foo/* foo/
315+
```
293316

294317
Please pay attention that this method does not have a strong built-in cache mechanism.
295318

appveyor.yml

-22
This file was deleted.

0 commit comments

Comments
 (0)