diff options
| author | BVegNow <117610616+BVegNow@users.noreply.github.com> | 2023-02-05 07:27:41 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-05 00:27:41 +0100 |
| commit | 9aaadcf12af081ff28d8c064d4b8835b51a64235 (patch) | |
| tree | 2e7d0760a3064e742821eced2f308a9b98fbc735 /lua | |
| parent | feat(registry): add gospel (#961) (diff) | |
| download | mason-9aaadcf12af081ff28d8c064d4b8835b51a64235.tar mason-9aaadcf12af081ff28d8c064d4b8835b51a64235.tar.gz mason-9aaadcf12af081ff28d8c064d4b8835b51a64235.tar.bz2 mason-9aaadcf12af081ff28d8c064d4b8835b51a64235.tar.lz mason-9aaadcf12af081ff28d8c064d4b8835b51a64235.tar.xz mason-9aaadcf12af081ff28d8c064d4b8835b51a64235.tar.zst mason-9aaadcf12af081ff28d8c064d4b8835b51a64235.zip | |
feat(windows): manually decompress zstd archives before untar (#963)
Co-authored-by: William Boman <william@redwill.se>
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/mason-core/managers/github/init.lua | 2 | ||||
| -rw-r--r-- | lua/mason-core/managers/std/init.lua | 36 |
2 files changed, 33 insertions, 5 deletions
diff --git a/lua/mason-core/managers/github/init.lua b/lua/mason-core/managers/github/init.lua index e9e4ec67..3feb2f20 100644 --- a/lua/mason-core/managers/github/init.lua +++ b/lua/mason-core/managers/github/init.lua @@ -132,7 +132,7 @@ M.unzip_release_file = release_file_processor("archive.zip", function() end) M.untarzst_release_file = release_file_processor("archive.tar.zst", function(opts) - std.untar("archive.tar.zst", { strip_components = opts.strip_components }) + std.untarzst("archive.tar.zst", { strip_components = opts.strip_components }) end) M.untarxz_release_file = release_file_processor("archive.tar.xz", function(opts) diff --git a/lua/mason-core/managers/std/init.lua b/lua/mason-core/managers/std/init.lua index 18c56b21..0b48ea66 100644 --- a/lua/mason-core/managers/std/init.lua +++ b/lua/mason-core/managers/std/init.lua @@ -98,15 +98,25 @@ end ---@async ---@param file string ----@param opts {strip_components:integer}? +---@param opts { strip_components?: integer }? function M.untar(file, opts) opts = opts or {} local ctx = installer.context() + local tarfile = string.gsub(file, ".zst$", "") + if platform.is.win and file ~= tarfile then + ctx.spawn.zstd { + "-d", + "-f", + "-o", + tarfile, + file, + } + end ctx.spawn.tar { opts.strip_components and { "--strip-components", opts.strip_components } or vim.NIL, "--no-same-owner", "-xvf", - file, + tarfile, } pcall(function() ctx.fs:unlink(file) @@ -115,7 +125,25 @@ end ---@async ---@param file string ----@param opts {strip_components: integer?}? +---@param opts { strip_components?: integer }? +function M.untarzst(file, opts) + opts = opts or {} + platform.when { + unix = function() + M.untar(file, opts) + end, + win = function() + local ctx = installer.context() + local uncompressed_tar = file:gsub("%.zst$", "") + ctx.spawn.zstd { "-dfo", uncompressed_tar, file } + M.untar(uncompressed_tar, opts) + end, + } +end + +---@async +---@param file string +---@param opts { strip_components?: integer }? function M.untarxz(file, opts) opts = opts or {} local ctx = installer.context() @@ -126,7 +154,7 @@ function M.untarxz(file, opts) win = function() Result.run_catching(function() win_decompress(file) -- unpack .tar.xz to .tar - local uncompressed_tar = file:gsub(".xz$", "") + local uncompressed_tar = file:gsub("%.xz$", "") M.untar(uncompressed_tar, opts) end):recover(function() ctx.spawn.arc { |
