refactor: Replace pull_releases function with iterator generator

Although the types are different, the intent is the same, so I think the
name is fitting.
This commit is contained in:
Thomas A. Christensen II 2024-01-26 16:45:19 -06:00
parent 91ef9fb65a
commit 2850a8553a
2 changed files with 4 additions and 21 deletions

View file

@ -12,8 +12,8 @@ import {
import { NextflowRelease } from "./nextflow-release"
import {
pull_latest_stable_release,
setup_octokit,
release_iter
pull_releases,
setup_octokit
} from "./octokit-wrapper"
async function run(): Promise<void> {
@ -43,7 +43,7 @@ async function run(): Promise<void> {
if (version === "latest" || version === "latest-stable") {
release = await pull_latest_stable_release(octokit)
} else {
const release_iterator = release_iter(octokit)
const release_iterator = pull_releases(octokit)
release = await get_nextflow_release(version, release_iterator)
}
resolved_version = release.versionNumber

View file

@ -51,7 +51,7 @@ export async function setup_octokit(
return octokit
}
export async function* release_iter(
export async function* pull_releases(
octokit: InstanceType<typeof GitHub>
): AsyncGenerator<NextflowRelease> {
const iterator = octokit.paginate.iterator(
@ -77,23 +77,6 @@ export async function* release_iter(
}
}
export async function pull_releases(
ok: InstanceType<typeof GitHub>
): Promise<NextflowRelease[]> {
return await ok.paginate(
ok.rest.repos.listReleases,
NEXTFLOW_REPO,
response => {
const all_releases: NextflowRelease[] = []
const releases_data = response.data
for (const release_data of releases_data) {
all_releases.push(nextflow_release(release_data))
}
return all_releases
}
)
}
export async function pull_latest_stable_release(
ok: InstanceType<typeof GitHub>
): Promise<NextflowRelease> {