You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26-6Lines changed: 26 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -298,7 +298,19 @@ interface TestResult {
298
298
-`{ignored: false, unignored: true}`: the `pathname` is unignored
299
299
-`{ignored: false, unignored: false}`: the `pathname` is never matched by any ignore rules.
300
300
301
-
## `options.ignorecase` since 4.0.0
301
+
## static `ignore.isPathValid(pathname): boolean` since 5.0.0
302
+
303
+
Check whether the `pathname` is an valid `path.relative()`d path according to the [convention](#1-pathname-should-be-a-pathrelatived-pathname).
304
+
305
+
This method is **NOT** used to check if an ignore pattern is valid.
306
+
307
+
```js
308
+
ignore.isPathValid('./foo') // false
309
+
```
310
+
311
+
## ignore(options)
312
+
313
+
### `options.ignorecase` since 4.0.0
302
314
303
315
Similar as the `core.ignorecase` option of [git-config](https://git-scm.com/docs/git-config), `node-ignore` will be case insensitive if `options.ignorecase` is set to `true` (the default value), otherwise case sensitive.
304
316
@@ -312,14 +324,20 @@ ig.add('*.png')
312
324
ig.ignores('*.PNG') // false
313
325
```
314
326
315
-
##static `ignore.isPathValid(pathname): boolean` since 5.0.0
327
+
### `options.ignoreCase?: boolean` since 5.2.0
316
328
317
-
Check whether the `pathname`is an valid `path.relative()`d path according to the [convention](#1-pathname-should-be-a-pathrelatived-pathname).
329
+
Which is alternative to `options.ignoreCase`
318
330
319
-
This method is **NOT** used to check if an ignore pattern is valid.
331
+
### `options.allowRelativePaths?: boolean` since 5.2.0
332
+
333
+
This option brings backward compatibility with projects which based on `[email protected]`
334
+
335
+
However, passing a relative path to test if it is ignored or not is not a good practise, which might lead to unexpected behavior
320
336
321
337
```js
322
-
ignore.isPathValid('./foo') // false
338
+
ignore({
339
+
allowRelativePaths:true
340
+
}).ignores('../foo/bar.js') // And it will not throw
Since `5.0.0`, if an invalid `Pathname` passed into `ig.ignores()`, an error will be thrown, while `ignore < 5.0.0` did not make sure what the return value was, as well as
349
+
Since `5.0.0`, if an invalid `Pathname` passed into `ig.ignores()`, an error will be thrown, unless `options.allowRelative = true` is passed to the `Ignore` factory.
350
+
351
+
While `ignore < 5.0.0` did not make sure what the return value was, as well as
0 commit comments