Skip to content

Commit 3c66d95

Browse files
committed
Docs: Fix the Negative Globs section & examples (closes #2297)
1 parent 1693a11 commit 3c66d95

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

docs/getting-started/6-explaining-globs.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,25 @@ Here, the glob is appropriately restricted to the `scripts/` directory. It will
4949

5050
## Special character: ! (negative)
5151

52-
Since globs are matched in array order, a negative glob must follow at least one non-negative glob in an array. The first finds a set of matches, then the negative glob removes a portion of those results. These are most performant when they only include literal characters.
52+
Since globs are matched in array order, a negative glob must follow at least one non-negative glob in an array. The first finds a set of matches, then the negative glob removes a portion of those results. When excluding all files within a directory, you must add `/**` after the directory name, which the globbing library optimizes internally.
5353

5454
```js
55-
['scripts/**/*.js', '!scripts/vendor/']
55+
['scripts/**/*.js', '!scripts/vendor/**']
5656
```
5757

5858
If any non-negative globs follow a negative, nothing will be removed from the later set of matches.
5959

6060
```js
61-
['scripts/**/*.js', '!scripts/vendor/', 'scripts/vendor/react.js']
61+
['scripts/**/*.js', '!scripts/vendor/**', 'scripts/vendor/react.js']
6262
```
6363

6464
Negative globs can be used as an alternative for restricting double-star globs.
6565

6666
```js
67-
['**/*.js', '!node_modules/']
67+
['**/*.js', '!node_modules/**']
6868
```
6969

70-
<small>In the previous example, if the negative glob was `!node_modules/**/*.js`, every match would have to be compared against the negative glob, which would be extremely slow.</small>
70+
<small>In the previous example, if the negative glob was `!node_modules/**/*.js`, the globbing library wouldn't optimize the negation and every match would have to be compared against the negative glob, which would be extremely slow. To ignore all files in a directory, only add the `/**` glob after the directory name.</small>
7171

7272
## Overlapping globs
7373

0 commit comments

Comments
 (0)