diff --git a/toolchainlib/src/init.luau b/toolchainlib/src/init.luau index a361fdd..5b605de 100644 --- a/toolchainlib/src/init.luau +++ b/toolchainlib/src/init.luau @@ -149,7 +149,6 @@ function installTool(tool: ToolId, installPath: pathfs.Path): number end end - barFns.stop(bar) return error(`No release found for version {version}`) end, @@ -211,7 +210,6 @@ function installTool(tool: ToolId, installPath: pathfs.Path): number local decompressedPath = downloadAndDecompress(matchingAsset):unwrap() binaryPath = decompressedPath:join(aliasPath) if not pathfs.isFile(binaryPath) then - barFns.stop(bar) error(`No matching binary found in {decompressedPath}`) end end @@ -328,6 +326,9 @@ return setmetatable( ) if not ok then + -- Cleanup progress bar in case of error + makeConditionalBar().stop(bar) + stdio.ewrite(`{ERROR_PREFIX} Failed to install {tool}\n`) stdio.ewrite(` - {err}\n`) return 1 diff --git a/toolchainlib/src/utils/progress.luau b/toolchainlib/src/utils/progress.luau index 4f79617..9c42572 100644 --- a/toolchainlib/src/utils/progress.luau +++ b/toolchainlib/src/utils/progress.luau @@ -55,10 +55,15 @@ function ProgressBar.start(self: ProgressBarImpl): () for _, spinner in SPINNERS do local stage = self.stages[self.currentStageIndex] stdio.write( - `\x1b[2K\x1b[0G{spinner} {stage.message}{string.rep(" ", MAX_MESSAGE_LENGTH - #stage.message)} [{string.rep( - BAR, - self.currentStageIndex - )}{string.rep(" ", TOTAL_BAR_LENGTH - (BAR_LENGTH * self.currentStageIndex))}] {self.currentStageIndex} / {#self.stages}` + `\x1b[2K\x1b[0G{stdio.color("cyan")}{spinner} {stage.message}{stdio.color("reset")}{string.rep( + " ", + MAX_MESSAGE_LENGTH - #stage.message + )} [{stdio.style("dim")}{string.rep(BAR, self.currentStageIndex)}{string.rep( + " ", + TOTAL_BAR_LENGTH - (BAR_LENGTH * self.currentStageIndex) + )}{stdio.style("reset")}] {stdio.style("bold")}{self.currentStageIndex} / {#self.stages}{stdio.style( + "reset" + )}` ) task.wait(0.1)