Skip to content
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

Merged
merged 1 commit into from
Nov 8, 2020

Conversation

billyvg
Copy link
Contributor

@billyvg billyvg commented Nov 7, 2020

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.

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.
Copy link
Owner

@dorny dorny left a 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', () => {
Copy link
Owner

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

Copy link
Contributor Author

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))) {
Copy link
Owner

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.

@dorny
Copy link
Owner

dorny commented Nov 8, 2020

Thank You 👍
I will shortly release new version with this merged and changes reflected in packaged dist/index.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants