mirror of
https://github.com/renovatebot/renovate.git
synced 2024-12-22 13:38:32 +00:00
23 lines
604 B
TypeScript
23 lines
604 B
TypeScript
import is from '@sindresorhus/is';
|
|
import type { PackageRule, PackageRuleInputConfig } from '../../config/types';
|
|
import { getRegexOrGlobPredicate } from '../string-match';
|
|
import { Matcher } from './base';
|
|
|
|
export class NewValueMatcher extends Matcher {
|
|
override matches(
|
|
{ newValue }: PackageRuleInputConfig,
|
|
{ matchNewValue }: PackageRule,
|
|
): boolean | null {
|
|
if (is.undefined(matchNewValue)) {
|
|
return null;
|
|
}
|
|
const matchNewValuePred = getRegexOrGlobPredicate(matchNewValue);
|
|
|
|
if (!newValue) {
|
|
return false;
|
|
}
|
|
|
|
return matchNewValuePred(newValue);
|
|
}
|
|
}
|