Skip to content

Negate pattern ordering #113

@DeclanCoughlan

Description

@DeclanCoughlan

Hi dorny,

Thanks for this package it helps greatly :)

I discovered the following unusual case, where ordering of the negated patterns seems to play a role.

test('negate all file patterns', () => {
    const yaml = `
    frontend:
      - '!(amplify/**|data/**|deploy/**)**'
    `
    let filter = new Filter(yaml)
    const files = modified(['data/jest.config.ts', 'amplify/backend/function/jest.config.ts', 'deploy/jest.config.ts' ])
    const match = filter.match(files)
    expect(match.frontend).toEqual([])
  })

The above breaks, however if the pattern is shuffled where the amplify/** pattern is placed at the end then it works (I tried numerous combinations, in the middle doesn't work either).

Conclusion

Works:

- '!(deploy/**|data/**|amplify/**)**'

Doesn't Work

- '!(amplify/**|data/**|deploy/**)**'

Error

image

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions