mirror of
https://github.com/MillironX/setup-nextflow.git
synced 2024-11-22 09:49:56 +00:00
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:
parent
91ef9fb65a
commit
2850a8553a
2 changed files with 4 additions and 21 deletions
|
@ -12,8 +12,8 @@ import {
|
||||||
import { NextflowRelease } from "./nextflow-release"
|
import { NextflowRelease } from "./nextflow-release"
|
||||||
import {
|
import {
|
||||||
pull_latest_stable_release,
|
pull_latest_stable_release,
|
||||||
setup_octokit,
|
pull_releases,
|
||||||
release_iter
|
setup_octokit
|
||||||
} from "./octokit-wrapper"
|
} from "./octokit-wrapper"
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
|
@ -43,7 +43,7 @@ async function run(): Promise<void> {
|
||||||
if (version === "latest" || version === "latest-stable") {
|
if (version === "latest" || version === "latest-stable") {
|
||||||
release = await pull_latest_stable_release(octokit)
|
release = await pull_latest_stable_release(octokit)
|
||||||
} else {
|
} else {
|
||||||
const release_iterator = release_iter(octokit)
|
const release_iterator = pull_releases(octokit)
|
||||||
release = await get_nextflow_release(version, release_iterator)
|
release = await get_nextflow_release(version, release_iterator)
|
||||||
}
|
}
|
||||||
resolved_version = release.versionNumber
|
resolved_version = release.versionNumber
|
||||||
|
|
|
@ -51,7 +51,7 @@ export async function setup_octokit(
|
||||||
return octokit
|
return octokit
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function* release_iter(
|
export async function* pull_releases(
|
||||||
octokit: InstanceType<typeof GitHub>
|
octokit: InstanceType<typeof GitHub>
|
||||||
): AsyncGenerator<NextflowRelease> {
|
): AsyncGenerator<NextflowRelease> {
|
||||||
const iterator = octokit.paginate.iterator(
|
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(
|
export async function pull_latest_stable_release(
|
||||||
ok: InstanceType<typeof GitHub>
|
ok: InstanceType<typeof GitHub>
|
||||||
): Promise<NextflowRelease> {
|
): Promise<NextflowRelease> {
|
||||||
|
|
Loading…
Reference in a new issue