mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-13 07:26:26 +00:00
31 lines
864 B
TypeScript
31 lines
864 B
TypeScript
import is from '@sindresorhus/is';
|
|
import type { PackageRule, PackageRuleInputConfig } from '../../config/types';
|
|
import { logger } from '../../logger';
|
|
import { configRegexPredicate } from '../regex';
|
|
import { Matcher } from './base';
|
|
|
|
export class CurrentValueMatcher extends Matcher {
|
|
override matches(
|
|
{ currentValue }: PackageRuleInputConfig,
|
|
{ matchCurrentValue }: PackageRule,
|
|
): boolean | null {
|
|
if (is.undefined(matchCurrentValue)) {
|
|
return null;
|
|
}
|
|
const matchCurrentValuePred = configRegexPredicate(matchCurrentValue);
|
|
|
|
if (!matchCurrentValuePred) {
|
|
logger.debug(
|
|
{ matchCurrentValue },
|
|
'matchCurrentValue should be a regex, starting and ending with `/`',
|
|
);
|
|
return false;
|
|
}
|
|
|
|
if (!currentValue) {
|
|
return false;
|
|
}
|
|
|
|
return matchCurrentValuePred(currentValue);
|
|
}
|
|
}
|