-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add support for multiple patterns when using file status #48
Conversation
This adds support for using multiple patterns when checking for file status (added, modified, deleted) and as a result also allows you to use YAML anchors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor changes are needed, but to not wait for each other I will do them on my own afterwards in separate PR.
@@ -165,6 +165,20 @@ describe('matching specific change status', () => { | |||
const match = filter.match(files) | |||
expect(match.addOrModify).toEqual(files) | |||
}) | |||
|
|||
test.only('matches when using an anchor', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the .only
modifier so all tests are executed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, forgot to remove this!
@@ -78,7 +78,7 @@ export class Filter { | |||
|
|||
if (typeof item === 'object') { | |||
return Object.entries(item).map(([key, pattern]) => { | |||
if (typeof key !== 'string' || typeof pattern !== 'string') { | |||
if (typeof key !== 'string' || (typeof pattern !== 'string' && !Array.isArray(pattern))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This basically tricks the typescript type system.
pattern
is declared as string
but it will be actually array of strings.
Micromatch library also accepts array of string but this signature is not documented there.
It's definitely just a documentation issue. matcher
method actually delegates to picomatch()
which indeed accepts string or array of strings.
To keep it simple. Let's leave it as it is and I will do some cleanup afterwards.
Thank You 👍 |
This adds support for using multiple patterns when checking for file status (added, modified, deleted) and as a result also allows you to use YAML anchors.