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: docs/getting-started/6-explaining-globs.md
+5-5
Original file line number
Diff line number
Diff line change
@@ -49,25 +49,25 @@ Here, the glob is appropriately restricted to the `scripts/` directory. It will
49
49
50
50
## Special character: ! (negative)
51
51
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.
53
53
54
54
```js
55
-
['scripts/**/*.js', '!scripts/vendor/']
55
+
['scripts/**/*.js', '!scripts/vendor/**']
56
56
```
57
57
58
58
If any non-negative globs follow a negative, nothing will be removed from the later set of matches.
Negative globs can be used as an alternative for restricting double-star globs.
65
65
66
66
```js
67
-
['**/*.js', '!node_modules/']
67
+
['**/*.js', '!node_modules/**']
68
68
```
69
69
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>
0 commit comments