Skip to content

Commit

Permalink
refactor function
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed May 9, 2024
1 parent 7982572 commit 4373e42
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions lib/workers/repository/process/lookup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ import {
isReplacementRulesConfigured,
} from './utils';

function getTimestamp(
versions: Release[],
version: string,
versioning: allVersioning.VersioningApi,
): string | null | undefined {
return versions.find(
(v) =>
versioning.isValid(v.version) && versioning.equals(v.version, version),
)?.releaseTimestamp;
}

export async function lookupUpdates(
inconfig: LookupUpdateConfig,
): Promise<Result<UpdateResult, Error>> {
Expand Down Expand Up @@ -287,11 +298,11 @@ export async function lookupUpdates(
}

res.currentVersion = currentVersion!;
const currentVersionTimestamp = allVersions.find(
(v) =>
versioning.isValid(v.version) &&
versioning.equals(v.version, currentVersion),
)?.releaseTimestamp;
const currentVersionTimestamp = getTimestamp(
allVersions,
currentVersion,
versioning,
);

if (is.nonEmptyString(currentVersionTimestamp)) {
res.currentVersionTimestamp = currentVersionTimestamp;
Expand Down

0 comments on commit 4373e42

Please sign in to comment.