Support more matching capabilties
lstrojny opened this issue · comments
https://github.com/axtgr/wildcard-match is used for matching the onlyOn
attribute. Unfortunately wildcard-match
does not support features like brace expansion (e.g. **/*.{js,ts}
to match .js
and .ts
files). Maybe it would be an alternative to adopt something like https://github.com/micromatch/micromatch to provide a bit more features.
Indeed, I don't really like the way the onlyOn
feature is implemented so far:
- It relies on some random js library and I am highly reluctant to that. I just don't have enough knowledge on the matter yet to come up with a nicer solution... Any inputs are welcome for this !
- It definitely lacks matching features like regexp vs patterns, brace expansion as you mentioned it
I'll look into the library you mentioned and it's companions so that I can decide if it's possible to add it
I'm struggling with this as well trying to do a negative lookahead.
const matcher = require('wildcard-match');
const globs = [
'**/*.jsx',
'**/*.js',
'(?!dont-match/)/**/*',
];
const match = matcher(globs)
console.log(match.regexp)
// /^(?:^(?:[^/\\]*?[/\\]+?)*?[^/\\]*?\.jsx[/\\]*?$|^(?:[^/\\]*?[/\\]+?)*?[^/\\]*?\.js[/\\]*?$|^\([^/\\]!dont\-match[/\\]+?\)[/\\]+?(?:[^/\\]*?[/\\]+?)*?[^/\\]*?[/\\]*?$)$/
maybe it's possible but I'm not sure 🤷
Hi!
I'm the author of wildcard-match. The library is indeed very basic and doesn't support many features. I have a more feature-packed library: outmatch. It has brace expansion, negation and other advanced features and should work as a drop-in replacement.
I understand the reluctance to use random libraries. In case you decide to stick to the more established ones, either micromatch or picomatch are a good choice.