-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from micromatch/fix-83
Fix 83
- Loading branch information
Showing
9 changed files
with
130 additions
and
49 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'use strict'; | ||
|
||
const picomatch = require('..'); | ||
|
||
const fixtures = [ | ||
['/file.d.ts', false], | ||
['/file.ts', true], | ||
['/file.d.something.ts', true], | ||
['/file.dhello.ts', true] | ||
]; | ||
|
||
const pattern = '/!(*.d).ts'; | ||
const isMatch = picomatch(pattern); | ||
|
||
console.log(fixtures.map(f => [isMatch(f[0]), f[1]])); |
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use strict'; | ||
|
||
const pico = require('..'); | ||
|
||
/** | ||
* See: https://github.com/gulpjs/glob-parent/issues/39#issuecomment-794075641 | ||
*/ | ||
|
||
const files = [ | ||
'data/100-123a_files/0/', | ||
'data/100-123a_files/1/', | ||
'data/100-123a_files/2/', | ||
'data/100-123a_files/3/', | ||
'data/100-123b_files/0/', | ||
'data/100-123b_files/1/', | ||
'data/100-123b_files/2/', | ||
'data/100-123b_files/3/', | ||
'data/100-123a_files/4/', | ||
'data/100-123ax_files/0/', | ||
'data/100-123A_files/0/', | ||
'data/100-123A_files/1/', | ||
'data/100-123A_files/2/', | ||
'data/100-123A_files/3/', | ||
'data/100-123B_files/0/', | ||
'data/100-123B_files/1/', | ||
'data/100-123B_files/2/', | ||
'data/100-123B_files/3/', | ||
'data/100-123A_files/4/', | ||
'data/100-123AX_files/0/' | ||
]; | ||
|
||
// ? is a wildcard for matching one character | ||
// by escaping \\{0,3}, and then using `{ unescape: true }, we tell | ||
// picomatch to treat those characters as a regex quantifier, versus | ||
// a brace pattern. | ||
|
||
const isMatch = pico('data/100-123?\\{0,3}_files/{0..3}/', { unescape: true }); | ||
console.log(files.filter(name => isMatch(name))); | ||
|
||
// Alternatively, we can use a regex character class to be more specific | ||
// In the following example, we'll only match uppercase alpha characters | ||
const isMatch2 = pico('data/100-123[A-Z]*_files/{0..3}/', { unescape: true }); | ||
console.log(files.filter(name => isMatch2(name))); |
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
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