mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-13 15:36:25 +00:00
27 lines
794 B
TypeScript
27 lines
794 B
TypeScript
import is from '@sindresorhus/is';
|
|
import type { PackageRule, PackageRuleInputConfig } from '../../config/types';
|
|
import { minimatch } from '../minimatch';
|
|
import { Matcher } from './base';
|
|
|
|
export class FileNamesMatcher extends Matcher {
|
|
override matches(
|
|
{ packageFile, lockFiles }: PackageRuleInputConfig,
|
|
{ matchFileNames }: PackageRule
|
|
): boolean | null {
|
|
if (is.undefined(matchFileNames)) {
|
|
return null;
|
|
}
|
|
if (is.undefined(packageFile)) {
|
|
return false;
|
|
}
|
|
|
|
return matchFileNames.some(
|
|
(matchFileName) =>
|
|
minimatch(matchFileName, { dot: true }).match(packageFile) ||
|
|
(is.array(lockFiles) &&
|
|
lockFiles.some((lockFile) =>
|
|
minimatch(matchFileName, { dot: true }).match(lockFile)
|
|
))
|
|
);
|
|
}
|
|
}
|