-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(package-rules)!: merge matchPaths and matchFiles into matchFileN…
…ames Closes #22395 BREAKING CHANGE: matchPaths and matchFiles are now combined and merged into matchFileNames
- Loading branch information
Showing
23 changed files
with
90 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,27 @@ | ||
import is from '@sindresorhus/is'; | ||
import { minimatch } from 'minimatch'; | ||
import type { PackageRule, PackageRuleInputConfig } from '../../config/types'; | ||
import { Matcher } from './base'; | ||
|
||
export class FilesMatcher extends Matcher { | ||
export class FileNamesMatcher extends Matcher { | ||
override matches( | ||
{ packageFile, lockFiles }: PackageRuleInputConfig, | ||
{ matchFiles }: PackageRule | ||
{ matchFileNames }: PackageRule | ||
): boolean | null { | ||
if (is.undefined(matchFiles)) { | ||
if (is.undefined(matchFileNames)) { | ||
return null; | ||
} | ||
if (is.undefined(packageFile)) { | ||
return false; | ||
} | ||
|
||
return matchFiles.some( | ||
(fileName) => | ||
packageFile === fileName || | ||
(is.array(lockFiles) && lockFiles?.includes(fileName)) | ||
return matchFileNames.some( | ||
(matchFileName) => | ||
minimatch(packageFile, matchFileName, { dot: true }) || | ||
(is.array(lockFiles) && | ||
lockFiles.some((lockFile) => | ||
minimatch(lockFile, matchFileName, { dot: true }) | ||
)) | ||
); | ||
} | ||
} |
Oops, something went wrong.