-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#75: main, README.md, test, ts: new options.allowRelativePaths to bri…
…ng backward compatibility
- Loading branch information
Showing
5 changed files
with
65 additions
and
19 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 |
---|---|---|
|
@@ -298,7 +298,19 @@ interface TestResult { | |
- `{ignored: false, unignored: true}`: the `pathname` is unignored | ||
- `{ignored: false, unignored: false}`: the `pathname` is never matched by any ignore rules. | ||
|
||
## `options.ignorecase` since 4.0.0 | ||
## static `ignore.isPathValid(pathname): boolean` since 5.0.0 | ||
|
||
Check whether the `pathname` is an valid `path.relative()`d path according to the [convention](#1-pathname-should-be-a-pathrelatived-pathname). | ||
|
||
This method is **NOT** used to check if an ignore pattern is valid. | ||
|
||
```js | ||
ignore.isPathValid('./foo') // false | ||
``` | ||
|
||
## ignore(options) | ||
|
||
### `options.ignorecase` since 4.0.0 | ||
|
||
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. | ||
|
||
|
@@ -312,14 +324,20 @@ ig.add('*.png') | |
ig.ignores('*.PNG') // false | ||
``` | ||
|
||
## static `ignore.isPathValid(pathname): boolean` since 5.0.0 | ||
### `options.ignoreCase?: boolean` since 5.2.0 | ||
|
||
Check whether the `pathname` is an valid `path.relative()`d path according to the [convention](#1-pathname-should-be-a-pathrelatived-pathname). | ||
Which is alternative to `options.ignoreCase` | ||
|
||
This method is **NOT** used to check if an ignore pattern is valid. | ||
### `options.allowRelativePaths?: boolean` since 5.2.0 | ||
|
||
This option brings backward compatibility with projects which based on `[email protected]` | ||
|
||
However, passing a relative path to test if it is ignored or not is not a good practise, which might lead to unexpected behavior | ||
|
||
```js | ||
ignore.isPathValid('./foo') // false | ||
ignore({ | ||
allowRelativePaths: true | ||
}).ignores('../foo/bar.js') // And it will not throw | ||
``` | ||
|
||
**** | ||
|
@@ -328,7 +346,9 @@ ignore.isPathValid('./foo') // false | |
|
||
## Upgrade 4.x -> 5.x | ||
|
||
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 | ||
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. | ||
|
||
While `ignore < 5.0.0` did not make sure what the return value was, as well as | ||
|
||
```ts | ||
.ignores(pathname: Pathname): boolean | ||
|
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
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