Skip to content

Commit

Permalink
fix(deps): update dependency minimatch to v5.1.0 (#3548)
Browse files Browse the repository at this point in the history
* fix(deps): update dependency minimatch to v5.1.0
* Use forward slashes in file matcher

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Nico Jansen <jansennico@gmail.com>
  • Loading branch information
3 people committed May 29, 2022
1 parent bb5611a commit c27ec2f
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 11 deletions.
55 changes: 48 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"jasmine-core": "4.1.1",
"json-schema-to-typescript": "10.1.5",
"lerna": "5.0.0",
"minimatch": "5.0.1",
"minimatch": "5.1.0",
"mocha": "10.0.0",
"prettier": "2.6.2",
"rimraf": "3.0.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"lodash.flatmap": "~4.5.0",
"lodash.groupby": "~4.6.0",
"log4js": "~6.4.1",
"minimatch": "~3.1.0",
"minimatch": "~5.1.0",
"mkdirp": "~1.0.3",
"mutation-testing-elements": "1.7.10",
"mutation-testing-metrics": "1.7.10",
Expand Down
14 changes: 12 additions & 2 deletions packages/core/src/config/file-matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,23 @@ export class FileMatcher {

constructor(pattern: string | false) {
if (pattern !== false) {
this.pattern = path.resolve(pattern);
this.pattern = toPosixFileName(path.resolve(pattern));
} else {
this.pattern = pattern;
}
}

public matches(fileName: string): boolean {
return !!this.pattern && minimatch(path.resolve(fileName), this.pattern);
return !!this.pattern && minimatch(toPosixFileName(path.resolve(fileName)), this.pattern);
}
}

/**
* Replaces backslashes with forward slashes. Minimatch only uses forward slashes
* @see https://github.com/isaacs/minimatch#windows
* @param fileName The file name that may contain backslashes `\`
* @returns posix and ts complaint file name (with `/`)
*/
export function toPosixFileName(fileName: string): string {
return fileName.replace(/\\/g, '/');
}

0 comments on commit c27ec2f

Please sign in to comment.