Skip to content

Commit 5935ee1

Browse files
authored
Merge pull request #96 from hkdobrev/matcher-efficiency
Simplify file matcher making it more efficient
2 parents fd33c79 + 907b2e9 commit 5935ee1

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

src/matcher.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/resolveMatchingPatterns.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import matcher from './matcher.js';
1+
import micromatch from 'micromatch';
22

3-
export default (list, config) => {
3+
export default (changedFiles, config) => {
44
const commandsToRun = Object.entries(config)
5-
.filter(([pattern]) => matcher(list, [pattern]))
6-
.map(([, commands]) => commands)
7-
// Flatten array
8-
.reduce((acc, val) => acc.concat(val), []);
5+
.filter(([pattern]) => micromatch.some(changedFiles, [pattern]))
6+
.flatMap(([, commands]) => commands);
97

108
// unique commands, do not run them multiple times if they are the same
119
// for multiple patterns or they are repeated in a list for a single pattern

0 commit comments

Comments
 (0)