Skip to content

Commit e9b7d58

Browse files
committed
feat: report the status of the installation in the end
1 parent 298e017 commit e9b7d58

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

src/main.ts

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import semverValid from "semver/functions/valid"
1818
import { getVersion } from "./default_versions"
1919
import { InstallationInfo } from "./utils/setup/setupBin"
2020
import { setupGcc } from "./gcc/gcc"
21-
import { assert } from "console"
2221

2322
const tools = [
2423
"cmake",
@@ -119,22 +118,45 @@ export async function main(): Promise<number> {
119118
}
120119
}
121120

121+
const toolsSucceeded: string[] = []
122+
const toolsErrored: string[] = []
122123
for (const tool of tools) {
123-
assert(tool in setups)
124124
const version = maybeGetInput(tool)
125125
if (version !== undefined) {
126126
const setupFunction = setups[tool]
127-
// eslint-disable-next-line no-await-in-loop
128-
await setupFunction(getVersion(tool, version), setupCppDir, arch)
127+
128+
try {
129+
// eslint-disable-next-line no-await-in-loop
130+
const installationInfo = await setupFunction(getVersion(tool, version), setupCppDir, arch)
131+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
132+
if (installationInfo !== undefined) {
133+
let success = `${tool} was successfully installed`
134+
if (installationInfo.installDir !== undefined) {
135+
success += `\nThe installation direcotry is ${installationInfo.installDir}`
136+
}
137+
if (installationInfo.binDir) {
138+
success += `\nThe binary direcotry is ${installationInfo.binDir}`
139+
}
140+
toolsSucceeded.push(success)
141+
} else {
142+
toolsSucceeded.push(`${tool} was successfully installed`)
143+
}
144+
} catch (e) {
145+
toolsErrored.push(`${tool} failed to install`)
146+
}
129147
}
130148
}
149+
150+
console.log("\n\n\n")
151+
toolsSucceeded.forEach((tool) => core.info(tool))
152+
toolsErrored.forEach((tool) => core.error(tool))
131153
} catch (err) {
132154
core.error(err as string | Error)
133155
core.setFailed("install-cpp failed")
134156
return 1
135157
}
136158

137-
core.info("install-cpp succeeded")
159+
core.info("install-cpp finished")
138160
return 0
139161
}
140162

0 commit comments

Comments
 (0)