From e9b7d582e2541197bbd773e282f1559bef7945a0 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 17 Sep 2021 07:43:01 -0500 Subject: [PATCH] feat: report the status of the installation in the end --- src/main.ts | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/main.ts b/src/main.ts index e13c7b8b..43fe95c9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -18,7 +18,6 @@ import semverValid from "semver/functions/valid" import { getVersion } from "./default_versions" import { InstallationInfo } from "./utils/setup/setupBin" import { setupGcc } from "./gcc/gcc" -import { assert } from "console" const tools = [ "cmake", @@ -119,22 +118,45 @@ export async function main(): Promise { } } + const toolsSucceeded: string[] = [] + const toolsErrored: string[] = [] for (const tool of tools) { - assert(tool in setups) const version = maybeGetInput(tool) if (version !== undefined) { const setupFunction = setups[tool] - // eslint-disable-next-line no-await-in-loop - await setupFunction(getVersion(tool, version), setupCppDir, arch) + + try { + // eslint-disable-next-line no-await-in-loop + const installationInfo = await setupFunction(getVersion(tool, version), setupCppDir, arch) + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if (installationInfo !== undefined) { + let success = `${tool} was successfully installed` + if (installationInfo.installDir !== undefined) { + success += `\nThe installation direcotry is ${installationInfo.installDir}` + } + if (installationInfo.binDir) { + success += `\nThe binary direcotry is ${installationInfo.binDir}` + } + toolsSucceeded.push(success) + } else { + toolsSucceeded.push(`${tool} was successfully installed`) + } + } catch (e) { + toolsErrored.push(`${tool} failed to install`) + } } } + + console.log("\n\n\n") + toolsSucceeded.forEach((tool) => core.info(tool)) + toolsErrored.forEach((tool) => core.error(tool)) } catch (err) { core.error(err as string | Error) core.setFailed("install-cpp failed") return 1 } - core.info("install-cpp succeeded") + core.info("install-cpp finished") return 0 }