Closed devongovett closed 7 years ago
Tests don't appear to be passing on windows already... Not sure about that.
If you like this PR, I'll go ahead and add the capture
method to micromatch as well, and update extglob with support for capture groups as well.
@jonschlinkert updated!
@devongovett great work, perfect PR all around! I sent you an invite to join the org. Thank you!
I accidentally pushed this up as a patch, since I was focused on a bugfix and I forgot I merged this in first. However, there shouldn't be anything breaking, it's really straight forward, and I tested extensively with micromatch and all tests pass.
@jonschlinkert awesome, thanks. I think it should be ok. I tested with micromatch as well, and added all of the nanomatch/extglob tests that I added to micromatch as well: https://github.com/micromatch/micromatch/pull/105.
This adds a new method
nanomatch.capture
, which returns captured matches from dynamic parts of a pattern (e.g. star, globstar). Should partially address https://github.com/micromatch/micromatch/issues/85.For example:
This is very useful for a number of purposes. My usecase is building a nested object with results of a glob. For example, given the path and pattern above:
It works by adding a
capture
option to the compiler, which causes capturing groups to be added to the generated regex for stars and globstars. This option is off by default, so everything continues working exactly the same for other methods.I couldn't get the documentation generator to run on my system, so if you could run it that would be great. Thanks for a great library!