Skip to content

Commit

Permalink
fix(std): manually call zstd on Windows (#1212)
Browse files Browse the repository at this point in the history
Closes #1207.
  • Loading branch information
williamboman authored Apr 14, 2023
1 parent 6845ccf commit 3664448
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion lua/mason-core/installer/managers/std.lua
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,32 @@ local function untar_compressed(rel_path)
}
end

---@async
---@param rel_path string
---@return Result
---@nodiscard
local function untar_zst(rel_path)
return platform.when {
unix = function()
return untar(rel_path)
end,
win = function()
local ctx = installer.context()
local uncompressed_tar = rel_path:gsub("%.zst$", "")
ctx.spawn.zstd { "-dfo", uncompressed_tar, rel_path }
ctx.fs:unlink(rel_path)
return untar(uncompressed_tar)
end,
}
end

-- Order is important.
local unpack_by_filename = _.cond {
{ _.matches "%.tar$", untar },
{ _.matches "%.tar%.gz$", untar },
{ _.matches "%.tar%.bz2$", untar },
{ _.matches "%.tar%.xz$", untar_compressed },
{ _.matches "%.tar%.zst$", untar_compressed },
{ _.matches "%.tar%.zst$", untar_zst },
{ _.matches "%.zip$", unzip },
{ _.matches "%.vsix$", unzip },
{ _.matches "%.gz$", gunzip },
Expand Down

0 comments on commit 3664448

Please sign in to comment.