Skip to content

Commit

Permalink
Report unmatched files
Browse files Browse the repository at this point in the history
  • Loading branch information
lykahb committed Mar 11, 2022
1 parent ca686e0 commit 1396714
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5405,6 +5405,11 @@ class Filter {
for (const [key, patterns] of Object.entries(this.rules)) {
result[key] = files.filter(file => this.isMatch(file, patterns));
}
if (!this.rules.hasOwnProperty('other')) {
const matchingFilenamesList = Object.values(result).flatMap(filteredFiles => filteredFiles.map(file => file.filename));
const matchingFilenamesSet = new Set(matchingFilenamesList);
result.other = files.filter(file => !matchingFilenamesSet.has(file.filename));
}
return result;
}
isMatch(file, patterns) {
Expand Down
7 changes: 7 additions & 0 deletions src/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ export class Filter {
for (const [key, patterns] of Object.entries(this.rules)) {
result[key] = files.filter(file => this.isMatch(file, patterns))
}

if (!this.rules.hasOwnProperty('other')) {
const matchingFilenamesList = Object.values(result).flatMap(filteredFiles => filteredFiles.map(file => file.filename))
const matchingFilenamesSet = new Set(matchingFilenamesList)
result.other = files.filter(file => !matchingFilenamesSet.has(file.filename))
}

return result
}

Expand Down

0 comments on commit 1396714

Please sign in to comment.