refactor: Move nextflow_bin_url function to NextflowRelease.ts

Nextflow binary URLs should be stored in the new NextflowRelease object, so
it should essentially be private for the NextflowRelease type. Move the
function to that file to signify that (but retain export for testing
purposes).
This commit is contained in:
Thomas A. Christensen II 2023-12-23 10:27:00 -07:00
parent 7cc27d1095
commit a97128956e
2 changed files with 20 additions and 14 deletions

View file

@ -7,3 +7,23 @@ export type NextflowRelease = {
binaryURL: string binaryURL: string
allBinaryURL: string allBinaryURL: string
} }
/**
* Gets the download URL of a Nextflow binary
* @param release A "release" data struct from OctoKit
* @param get_all Whether to return the url for the "all" variant of Nextflow
* @returns The URL of the Nextflow binary
*/
export function nextflow_bin_url(release: object, get_all: boolean): string {
const release_assets = release["assets"]
const all_asset = release_assets.filter((a: object) => {
return a["browser_download_url"].endsWith("-all")
})[0]
const regular_asset = release_assets.filter((a: object) => {
return a["name"] === "nextflow"
})[0]
const dl_asset = get_all ? all_asset : regular_asset
return dl_asset.browser_download_url
}

View file

@ -72,20 +72,6 @@ export async function release_data(
return matching_releases[0] return matching_releases[0]
} }
export function nextflow_bin_url(release: object, get_all: boolean): string {
const release_assets = release["assets"]
const all_asset = release_assets.filter((a: object) => {
return a["browser_download_url"].endsWith("-all")
})[0]
const regular_asset = release_assets.filter((a: object) => {
return a["name"] === "nextflow"
})[0]
const dl_asset = get_all ? all_asset : regular_asset
return dl_asset.browser_download_url
}
export async function install_nextflow( export async function install_nextflow(
url: string, url: string,
version: string version: string