From 545262d3b97f4ea015f26dccb9739a6a5fc642e3 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Tue, 16 May 2023 18:13:04 -0500 Subject: [PATCH] feat: Add tool-cache checking function --- src/functions.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/functions.ts b/src/functions.ts index d5b6807..6685bf0 100644 --- a/src/functions.ts +++ b/src/functions.ts @@ -111,3 +111,22 @@ export async function install_nextflow( return temp_install_dir } + +export function check_cache(version: string): boolean { + const cleaned_version = semver.clean(version, true) + if (cleaned_version === null) { + return false + } + const resolved_version = String(cleaned_version) + + const nf_path = tc.find("nextflow", resolved_version) + if (!nf_path) { + core.debug(`Could not find Nextflow ${resolved_version} in the tool cache`) + return false + } else { + core.debug(`Found Nextflow ${resolved_version} at path '${nf_path}'`) + core.debug(`Adding '${nf_path}' to PATH`) + core.addPath(nf_path) + return true + } +}