0
0
mirror of https://github.com/renovatebot/renovate.git synced 2024-12-22 13:38:32 +00:00
renovatebot_renovate/lib/util/package-rules/current-age.ts
RahulGautamSingh 897066123f
feat(config/package-rules): matchCurrentAge (#23264)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2024-01-25 05:12:39 +00:00

22 lines
606 B
TypeScript

import is from '@sindresorhus/is';
import type { PackageRule, PackageRuleInputConfig } from '../../config/types';
import { satisfiesDateRange } from '../pretty-time';
import { Matcher } from './base';
export class CurrentAgeMatcher extends Matcher {
override matches(
{ currentVersionTimestamp }: PackageRuleInputConfig,
{ matchCurrentAge }: PackageRule,
): boolean | null {
if (!is.string(matchCurrentAge)) {
return null;
}
if (!is.string(currentVersionTimestamp)) {
return false;
}
return satisfiesDateRange(currentVersionTimestamp, matchCurrentAge);
}
}