-
-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
treat invalid classes as non-matching patterns
- Loading branch information
Showing
5 changed files
with
119 additions
and
16 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,51 @@ | ||
/* IMPORTANT | ||
* This snapshot file is auto-generated, but designed for humans. | ||
* It should be checked into source control and tracked carefully. | ||
* Re-generate by setting TAP_SNAPSHOT=1 and running tests. | ||
* Make sure to inspect the output below. Do not ignore changes! | ||
*/ | ||
'use strict' | ||
exports[`test/class-edge-cases.js TAP > must match snapshot 1`] = ` | ||
Object { | ||
"files": Array [ | ||
"a[]b", | ||
"[b-a]x", | ||
"a]b", | ||
"a[]]b", | ||
"a[[]b", | ||
], | ||
"matches": Object { | ||
"[b-a\\\\]*": Array [ | ||
"[b-a]x", | ||
], | ||
"\\\\[b-a]*": Array [ | ||
"[b-a]x", | ||
], | ||
"a[[]]*": Array [ | ||
"a[]b", | ||
"a[]]b", | ||
], | ||
"a[[]*": Array [ | ||
"a[]b", | ||
"a[]]b", | ||
"a[[]b", | ||
], | ||
"a[]]*": Array [ | ||
"a]b", | ||
], | ||
"a[]*": Array [ | ||
"a[]b", | ||
"a[]]b", | ||
], | ||
}, | ||
"patterns": Array [ | ||
"\\\\[b-a]*", | ||
"[b-a\\\\]*", | ||
"a[]*", | ||
"[b-a]*", | ||
"a[]]*", | ||
"a[[]*", | ||
"a[[]]*", | ||
], | ||
} | ||
` |
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,48 @@ | ||
const t = require('tap') | ||
const minimatch = require('../') | ||
|
||
const files = [ | ||
'a[]b', | ||
'[b-a]x', | ||
'a]b', | ||
'a[]]b', | ||
'a[[]b', | ||
] | ||
|
||
const patterns = [ | ||
'\\[b-a]*', | ||
'[b-a\\]*', | ||
'a[]*', | ||
'[b-a]*', | ||
'a[]]*', | ||
'a[[]*', | ||
'a\[[]]*' | ||
] | ||
|
||
// uncomment and pipe stderr into a bash script to test bash behavior | ||
// console.error('mkdir x; cd x; shopt -s nullglob') | ||
// for (const f of files) { | ||
// console.error(`touch '${JSON.stringify(f).slice(1, -1)}'`) | ||
// } | ||
// | ||
// console.error('ls -laF') | ||
// for (const p of patterns) { | ||
// console.error(`echo PATTERN='${p}'`) | ||
// console.error(`for i in ${p}; do echo "$i"; done`) | ||
// } | ||
// | ||
// console.error('cd ..; rm -rf x') | ||
|
||
const matches = {} | ||
|
||
for (const pattern of patterns) { | ||
for (const file of files) { | ||
if (minimatch(file, pattern)) { | ||
matches[pattern] = matches[pattern] || [] | ||
matches[pattern].push(file) | ||
} | ||
} | ||
} | ||
|
||
t.comment({files, patterns, matches}) | ||
t.matchSnapshot({files, patterns, matches}) |
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