Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
refactor: getRegistryReleases wrapper
  • Loading branch information
rarkins committed Jun 23, 2020
1 parent 031ad87 commit a905012
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lib/datasource/index.ts
Expand Up @@ -30,6 +30,15 @@ function load(datasource: string): Promise<Datasource> {

type GetReleasesInternalConfig = GetReleasesConfig & GetPkgReleasesConfig;

async function getRegistryReleases(
datasource,
config: GetReleasesConfig,
registryUrl: string
): Promise<ReleaseResult> {
const res = await datasource.getReleases({ ...config, registryUrl });
return res;
}

function firstRegistry(
config: GetReleasesInternalConfig,
datasource: Datasource,
Expand All @@ -42,10 +51,7 @@ function firstRegistry(
);
}
const registryUrl = registryUrls[0];
return datasource.getReleases({
...config,
registryUrl,
});
return getRegistryReleases(datasource, config, registryUrl);
}

async function huntRegistries(
Expand All @@ -57,10 +63,7 @@ async function huntRegistries(
let datasourceError;
for (const registryUrl of registryUrls) {
try {
res = await datasource.getReleases({
...config,
registryUrl,
});
res = await getRegistryReleases(datasource, config, registryUrl);
if (res) {
break;
}
Expand Down Expand Up @@ -89,10 +92,7 @@ async function mergeRegistries(
let datasourceError;
for (const registryUrl of registryUrls) {
try {
const res = await datasource.getReleases({
...config,
registryUrl,
});
const res = await getRegistryReleases(datasource, config, registryUrl);
if (combinedRes) {
combinedRes = { ...res, ...combinedRes };
combinedRes.releases = [...combinedRes.releases, ...res.releases];
Expand Down

0 comments on commit a905012

Please sign in to comment.