Skip to content

Commit

Permalink
apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
RahulGautamSingh committed Nov 22, 2024
1 parent bdc1837 commit 20a6168
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions lib/modules/datasource/cpan/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { logger } from '../../../logger';
import { cache } from '../../../util/cache/package/decorator';
import { joinUrlParts } from '../../../util/url';
import * as perlVersioning from '../../versioning/perl';
Expand Down Expand Up @@ -108,19 +109,23 @@ export class CpanDatasource extends Datasource {
homepage: `https://metacpan.org/pod/${packageName}`,
};

const latestVersionUrl = joinUrlParts(
registryUrl,
'v1/module/',
packageName,
);
const latestVersionRes = (
await this.http.getJson<MetaCpanApiFile>(latestVersionUrl)
).body;
const latestVersion = latestVersionRes.module[0].version;
try {
const latestVersionUrl = joinUrlParts(
registryUrl,
'v1/module/',
packageName,
);
const latestVersionRes = (
await this.http.getJson<MetaCpanApiFile>(latestVersionUrl)
).body;
const latestVersion = latestVersionRes?.module?.[0]?.version;

if (latestVersion) {
result.tags ??= {};
result.tags.latest ??= latestVersion;
if (latestVersion) {
result.tags ??= {};
result.tags.latest ??= latestVersion;
}
} catch {
logger.debug(`Error while fetching latest tag for ${packageName}.`);

Check warning on line 128 in lib/modules/datasource/cpan/index.ts

View check run for this annotation

Codecov / codecov/patch

lib/modules/datasource/cpan/index.ts#L128

Added line #L128 was not covered by tests
}
}
}
Expand Down

0 comments on commit 20a6168

Please sign in to comment.