Skip to content

Commit f45e43f

Browse files
committed
chore: we don't need to keep looping
1 parent bf6cf09 commit f45e43f

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

lib/inputs/file-pattern/static.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,20 @@ import { ExtractAction, ExtractedLayers } from "../../extractor/types";
55
import { streamToString } from "../../stream-utils";
66
import { ManifestFile } from "../../types";
77

8+
/**
9+
* Return false if any exclusion pattern matches,
10+
* return true if any inclusion pattern matches
11+
*/
812
function generatePathMatcher(
913
globsInclude: string[],
1014
globsExclude: string[],
1115
): (filePath: string) => boolean {
1216
return (filePath: string): boolean => {
13-
let exclude = false;
14-
for (const g of globsExclude) {
15-
if (!exclude && minimatch(filePath, g)) {
16-
exclude = true;
17-
}
18-
}
19-
if (!exclude) {
20-
for (const g of globsInclude) {
21-
if (minimatch(filePath, g)) {
22-
return true;
23-
}
24-
}
17+
if (globsExclude.some(glob => minimatch(filePath, glob))) {
18+
return false;
2519
}
26-
return false;
20+
21+
return globsInclude.some(glob => minimatch(filePath, glob));
2722
};
2823
}
2924

0 commit comments

Comments
 (0)