micromatch / extglob Goto Github PK
View Code? Open in Web Editor NEWExtended globs. Add (almost) the expressive power of regular expressions to glob patterns.
License: MIT License
Extended globs. Add (almost) the expressive power of regular expressions to glob patterns.
License: MIT License
npm install [email protected]
creates the file node_modules/extglob/lib/.DS_Store
I'm not using macOS so I'm pretty sure it's not at my end.
I'm not a huge fan of the debug
module. It requires localStorage
in the browser so if you try to browserify/webpack it for usage in a chrome extension/app, the code throws. Have you thought about using https://www.npmjs.com/package/debuglog instead?
While working on the refactor, these were the only patterns where Bash 4.3 disagreed with the results from this library. (fwiw minimatch fails 37 of the these tests).
I believe extglob is correct on most of these - this is only a few patterns with multiple examples for clarity (for example, IMHO !(foo)*
should not match foo
). I'd like some feedback on what the "verdict" should be.
edited 2016-10-17: most of these now agree. I realized that (in most of the listed cases) Bash is doing a "contains" match versus an "exact" match. Also, fwiw minimatch agrees with extglob on all cases except for the one minimatch fails on (which extglob and bash agree on). Unfortunately I've not been able to identify a specific reason that bash or minimatch disagree with this library on any cases - but it's clear that extglob is much more accurate than minimatch, and it appears that extglob is also more accurate than bash (it's known that bash still fails some edge cases).
String | Pattern | Bash | Extglob | Minimatch | Agreed? |
---|---|---|---|---|---|
foo | !(foo)* |
true | true | true | ✓ |
bar | !(foo)* |
true | true | true | ✓ |
baz | !(foo)* |
true | true | true | ✓ |
foobar | !(foo)* |
true | true | true | ✓ |
foo | *(!(foo)) |
true | false | true | ✓ |
moo.cow | !(*.*).!(*.*) |
true | true | true | ✓ |
mad.moo.cow | !(*.*).!(*.*) |
false | true | true | X |
foo.js.js | *.!(js) |
true | true | true | ✓ |
foo.js.js | *.!(js)* |
true | false | false | X |
foo.js.js | *.!(js)+ |
false | false | false | ✓ |
foo.js.js | *.!(js)*.!(js) |
false | false | false | ✓ |
Notes
One thing to consider is that whereas in bash, the extglob pattern might be the complete pattern, with this library the pattern is more likely to be a part of a larger glob pattern for testing file paths, etc.
Parser/compiler will be moved to https://github.com/jonschlinkert/snapdragon.
Hello,
I am using extglob v2.0.2 and node v8.9.0.
As the title states, there is a case where a pattern does not match where I thought it would.
extglob.makeRe("!(*.js|*.json)").test("a.js.gz") === true // KO
extglob.makeRe("!(*.js|*.json)").test("a.json.gz") === true // KO
extglob.makeRe("!(*.js|*.json)").test("a.gz") === true // OK
Should this not match or is it a bug?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.