From 2850a8553a031393a3028c20aae0aa2be8a6ebd8 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Fri, 26 Jan 2024 16:45:19 -0600 Subject: [PATCH] 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. --- src/main.ts | 6 +++--- src/octokit-wrapper.ts | 19 +------------------ 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/src/main.ts b/src/main.ts index 80d7fe8..2ab9555 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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 { @@ -43,7 +43,7 @@ async function run(): Promise { 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 diff --git a/src/octokit-wrapper.ts b/src/octokit-wrapper.ts index 4dc8af4..0c34083 100644 --- a/src/octokit-wrapper.ts +++ b/src/octokit-wrapper.ts @@ -51,7 +51,7 @@ export async function setup_octokit( return octokit } -export async function* release_iter( +export async function* pull_releases( octokit: InstanceType ): AsyncGenerator { const iterator = octokit.paginate.iterator( @@ -77,23 +77,6 @@ export async function* release_iter( } } -export async function pull_releases( - ok: InstanceType -): Promise { - 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 ): Promise {