Skip to content

Commit b37d4e9

Browse files
authored
Use micromatch instead of minimatch (#46)
* Use micromatch instead of minimatch micromatch claims to support full Bash 4.3 spec and it actually passes all the tests. For example this fixes processing of '!(**/*.tsx|**/*.less)' pattern - needed by #45 * Update CHANGELOG.md
1 parent 7b5334d commit b37d4e9

File tree

7 files changed

+12063
-9005
lines changed

7 files changed

+12063
-9005
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## v2.5.1
4+
- [Improved path matching with micromatch](https://github.com/dorny/paths-filter/pull/46)
5+
36
## v2.5.0
47
- [Support workflows triggered by any event](https://github.com/dorny/paths-filter/pull/44)
58

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,24 @@ doesn't allow this because they doesn't work on a level of individual jobs or st
5252
For more scenarios see [examples](#examples) section.
5353
5454
## Notes:
55-
- Paths expressions are evaluated using [minimatch](https://github.com/isaacs/minimatch) library.
55+
- Paths expressions are evaluated using [micromatch](https://github.com/micromatch/micromatch) library.
5656
Documentation for path expression format can be found on project github page.
57-
- Minimatch [dot](https://www.npmjs.com/package/minimatch#dot) option is set to true.
57+
- Micromatch [dot](https://github.com/micromatch/micromatch#options) option is set to true.
5858
Globbing will match also paths where file or folder name starts with a dot.
5959
- It's recommended to quote your path expressions with `'` or `"`. Otherwise you will get an error if it starts with `*`.
6060
- Local execution with [act](https://github.com/nektos/act) works only with alternative runner image. Default runner doesn't have `git` binary.
6161
- Use: `act -P ubuntu-latest=nektos/act-environments-ubuntu:18.04`
6262

6363

6464
# What's New
65+
- Paths expressions are now evaluated using [micromatch](https://github.com/micromatch/micromatch) library
6566
- Support workflows triggered by any event
6667
- Fixed compatibility with older (<2.23) versions of git
6768
- Support for tag pushes and tags as a base reference
6869
- Fixes for various edge cases when event payload is incomplete
6970
- Supports local execution with [act](https://github.com/nektos/act)
7071
- Fixed behavior of feature branch workflow:
71-
- Detects only changes introduced by feature branch. Later modifications on base branch are ignored.
72+
- Detects only changes introduced by feature branch. Later modifications on base branch are ignored
7273
- Filter by type of file change:
7374
- Optionally consider if file was added, modified or deleted
7475

__tests__/filter.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,25 @@ describe('matching tests', () => {
9898
expect(match.dot).toEqual(files)
9999
})
100100

101+
test('matches all except tsx and less files (negate a group with or-ed parts)', () => {
102+
const yaml = `
103+
backend:
104+
- '!(**/*.tsx|**/*.less)'
105+
`
106+
const filter = new Filter(yaml)
107+
const tsxFiles = modified(['src/ui.tsx'])
108+
const lessFiles = modified(['src/ui.less'])
109+
const pyFiles = modified(['src/server.py'])
110+
111+
const tsxMatch = filter.match(tsxFiles)
112+
const lessMatch = filter.match(lessFiles)
113+
const pyMatch = filter.match(pyFiles)
114+
115+
expect(tsxMatch.backend).toEqual([])
116+
expect(lessMatch.backend).toEqual([])
117+
expect(pyMatch.backend).toEqual(pyFiles)
118+
})
119+
101120
test('matches path based on rules included using YAML anchor', () => {
102121
const yaml = `
103122
shared: &shared

0 commit comments

Comments
 (0)