Closed Mitsunee closed 2 years ago
@Mitsunee I will improve the glob one of these days
@Mitsunee, in Nano Staged glob-parser using globstars options if pattern includes slash: https://github.com/usmanyunusov/nano-staged/blob/238d3eccab07c3a59ce3943fa732db8db225a512/lib/cmd-runner.js#L22
Example:
nano-staged glob
- https://stackblitz.com/edit/node-fdhfkh
micromatch
- https://stackblitz.com/edit/node-7gtp1t
Looks good to me, thanks šš»
Use case
I have a codebase with some customized svg icons and would like to automatically run
*.svg
throughsvgo
, but not touch*.inkscape.svg
files. Withlint-staged
I solved this with the pattern"**/!(*inkscape).svg"
.Expected behaviour
pattern matches any string unless it contains
inkscape
immediatly before.svg
Actual behaviour
foo.bar.svg
is not matched.Reproduction Steps:
I wrote the following test file to simulate my use-case:
I tried adjusting the pattern by (re)moving the single star and got the same result each time.
In addition I cloned the repository of
micromatch
(whichlint-staged
uses for glob pattern matching) and wrote the following tests to confirm my existing setup works as intended (all four tests passed):