From 444e8b904bd40e53e0018422fb97b13686440a9c Mon Sep 17 00:00:00 2001 From: Ruud Senden <8635138+rsenden@users.noreply.github.com> Date: Fri, 22 Sep 2023 14:13:33 +0200 Subject: [PATCH] chore: Minor improvements --- setup/dist/index.js | 16 ++++++++-------- setup/src/main.ts | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/setup/dist/index.js b/setup/dist/index.js index fc6c57a..57d2aa9 100644 --- a/setup/dist/index.js +++ b/setup/dist/index.js @@ -6602,7 +6602,7 @@ function installAndConfigure(internalFcliCmd, toolName, toolVersion) { core.info(`Skipping ${toolName} installation`); } else { - const installPath = yield installIfNotCached(internalFcliCmd, toolName, toolVersion); + const installPath = yield installIfNotCached(internalFcliCmd, toolName, toolVersion, core.info); exportVariables(toolName, toolVersion, installPath); } }); @@ -6612,17 +6612,17 @@ function installAndConfigure(internalFcliCmd, toolName, toolVersion) { * This function doesn't export any variables; this is handled by installAndConfigure * if applicable. */ -function installIfNotCached(internalFcliCmd, toolName, toolVersion) { +function installIfNotCached(internalFcliCmd, toolName, toolVersion, log) { return __awaiter(this, void 0, void 0, function* () { const installPath = `/opt/fortify/${toolName}/${toolVersion}`; // We explicitly don't use GitHub tool-cache as we support semantic versioning; // versions like 'latest' or 'v2' may change over time so we don't want to use - // an older cached version. + // an older cached version in case new versions are released. if (fs.existsSync(installPath)) { - core.info(`Using previously installed ${toolName} ${toolVersion}`); + log(`Using previously installed ${toolName} ${toolVersion}`); } else { - core.info(`Installing ${toolName} ${toolVersion}`); + log(`Installing ${toolName} ${toolVersion}`); yield install(internalFcliCmd, toolName, toolVersion, installPath); } return installPath; @@ -6743,9 +6743,9 @@ function getToolVersion(tool) { function main() { return __awaiter(this, void 0, void 0, function* () { try { - // Install fixed fcli version for internal action use by this - // action only. - const internalFcliCmd = core.toPlatformPath((yield installIfNotCached('', 'fcli', INTERNAL_FCLI_VERSION)) + '/bin/fcli'); + // Install fixed fcli version for internal action use by this action only. + const internalFcliPath = yield installIfNotCached('', 'fcli', INTERNAL_FCLI_VERSION, core.debug); + const internalFcliCmd = core.toPlatformPath(`${internalFcliPath}/bin/fcli`); // Install user-specified tools const tools = ['fcli', 'sc-client', 'fod-uploader', 'vuln-exporter']; for (const tool of tools) { diff --git a/setup/src/main.ts b/setup/src/main.ts index 502b4e7..19ec6cf 100644 --- a/setup/src/main.ts +++ b/setup/src/main.ts @@ -16,7 +16,7 @@ async function installAndConfigure(internalFcliCmd: string, toolName: string, to if (toolVersion==='skip') { core.info(`Skipping ${toolName} installation`); } else { - const installPath = await installIfNotCached(internalFcliCmd, toolName, toolVersion); + const installPath = await installIfNotCached(internalFcliCmd, toolName, toolVersion, core.info); exportVariables(toolName, toolVersion, installPath) } } @@ -26,15 +26,15 @@ async function installAndConfigure(internalFcliCmd: string, toolName: string, to * This function doesn't export any variables; this is handled by installAndConfigure * if applicable. */ -async function installIfNotCached(internalFcliCmd: string, toolName: string, toolVersion: string): Promise { +async function installIfNotCached(internalFcliCmd: string, toolName: string, toolVersion: string, log: (arg: string) => void): Promise { const installPath = `/opt/fortify/${toolName}/${toolVersion}`; // We explicitly don't use GitHub tool-cache as we support semantic versioning; // versions like 'latest' or 'v2' may change over time so we don't want to use - // an older cached version. + // an older cached version in case new versions are released. if (fs.existsSync(installPath)) { - core.info(`Using previously installed ${toolName} ${toolVersion}`); + log(`Using previously installed ${toolName} ${toolVersion}`); } else { - core.info(`Installing ${toolName} ${toolVersion}`); + log(`Installing ${toolName} ${toolVersion}`); await install(internalFcliCmd, toolName, toolVersion, installPath); } return installPath; @@ -144,9 +144,9 @@ function getToolVersion(tool: string): string { */ async function main(): Promise { try { - // Install fixed fcli version for internal action use by this - // action only. - const internalFcliCmd = core.toPlatformPath(await installIfNotCached('', 'fcli', INTERNAL_FCLI_VERSION)+'/bin/fcli'); + // Install fixed fcli version for internal action use by this action only. + const internalFcliPath = await installIfNotCached('', 'fcli', INTERNAL_FCLI_VERSION, core.debug); + const internalFcliCmd = core.toPlatformPath(`${internalFcliPath}/bin/fcli`); // Install user-specified tools const tools = ['fcli', 'sc-client', 'fod-uploader', 'vuln-exporter']