fix(lib): handle result conditionally too

Previously, we were calling `:unwrap` while trying to increment the
progress bar even if we were not in an interactive environment. This
fixes that.
This commit is contained in:
Erica Marigold 2024-12-25 15:48:50 +00:00
parent 35fb2df3a4
commit aba182cea5
Signed by: DevComp
GPG key ID: 429EF1C337871656

View file

@ -130,7 +130,9 @@ local function makeConditionalBar()
end end
return { return {
next = makeConditional(bar.nextStage), next = makeConditional(function(bar)
return bar:nextStage():unwrap()
end),
start = makeConditional(bar.start), start = makeConditional(bar.start),
stop = makeConditional(bar.stop), stop = makeConditional(bar.stop),
} }
@ -162,7 +164,7 @@ function installTool(tool: ToolId, installPath: pathfs.Path): number
}) :: Option<Github.Config> }) :: Option<Github.Config>
) )
barFns.next(bar):unwrap() -- fetch barFns.next(bar) -- fetch
local releases = client:queueTransactions({ "FetchReleases" })[1]:unwrap() :: GithubReleases local releases = client:queueTransactions({ "FetchReleases" })[1]:unwrap() :: GithubReleases
local assets = tool.version:match({ local assets = tool.version:match({
Some = function(version: string) Some = function(version: string)
@ -180,7 +182,7 @@ function installTool(tool: ToolId, installPath: pathfs.Path): number
end, end,
}) })
barFns.next(bar):unwrap() -- locate barFns.next(bar) -- locate
-- TODO: Use index type fn in solver v2 -- TODO: Use index type fn in solver v2
local matchingAsset: { local matchingAsset: {
name: string, name: string,
@ -204,7 +206,7 @@ function installTool(tool: ToolId, installPath: pathfs.Path): number
end end
end end
barFns.next(bar):unwrap() -- download barFns.next(bar) -- download
local binaryPath: pathfs.Path local binaryPath: pathfs.Path
if matchingAsset == nil then if matchingAsset == nil then
@ -235,7 +237,7 @@ function installTool(tool: ToolId, installPath: pathfs.Path): number
end end
end end
barFns.next(bar):unwrap() -- install barFns.next(bar) -- install
-- Maintain multiple versions of a tool, and avoid downloading -- Maintain multiple versions of a tool, and avoid downloading
-- the binary for a version again if it's already there -- the binary for a version again if it's already there