aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorN.N <113419913+nnlq@users.noreply.github.com>2022-11-07 22:10:02 +0700
committerGitHub <noreply@github.com>2022-11-07 16:10:02 +0100
commita096949e83b3054c9aa237336a2347effd4f2f05 (patch)
tree8c8c10ff9a9250d6ca0f836837167f7effe37951 /lua
parentchore: update generated code (#643) (diff)
downloadmason-a096949e83b3054c9aa237336a2347effd4f2f05.tar
mason-a096949e83b3054c9aa237336a2347effd4f2f05.tar.gz
mason-a096949e83b3054c9aa237336a2347effd4f2f05.tar.bz2
mason-a096949e83b3054c9aa237336a2347effd4f2f05.tar.lz
mason-a096949e83b3054c9aa237336a2347effd4f2f05.tar.xz
mason-a096949e83b3054c9aa237336a2347effd4f2f05.tar.zst
mason-a096949e83b3054c9aa237336a2347effd4f2f05.zip
fix(rustfmt): use correct asset names and use unzip on windows (#644)
Diffstat (limited to 'lua')
-rw-r--r--lua/mason-registry/rustfmt/init.lua40
1 files changed, 24 insertions, 16 deletions
diff --git a/lua/mason-registry/rustfmt/init.lua b/lua/mason-registry/rustfmt/init.lua
index e8a03daf..c53aa98a 100644
--- a/lua/mason-registry/rustfmt/init.lua
+++ b/lua/mason-registry/rustfmt/init.lua
@@ -2,6 +2,7 @@ local Pkg = require "mason-core.package"
local _ = require "mason-core.functional"
local platform = require "mason-core.platform"
local github = require "mason-core.managers.github"
+local path = require "mason-core.path"
local coalesce, when = _.coalesce, _.when
@@ -11,22 +12,29 @@ return Pkg.new {
homepage = "https://github.com/rust-lang/rustfmt",
categories = { Pkg.Cat.Formatter },
languages = { Pkg.Lang.Rust },
+ ---@async
+ ---@param ctx InstallContext
install = function(ctx)
- ---@param template_string string
- local function release_file(template_string)
- return _.compose(_.format(template_string), _.gsub("^v", ""))
- end
-
- github
- .untargz_release_file({
- repo = "rust-lang/rustfmt",
- asset_file = coalesce(
- when(platform.is.mac, release_file "rustfmt_macos-x86_64_%s.tar.gz"),
- when(platform.is.linux_x64, release_file "rustfmt_linux-x86_64_%s.tar.gz"),
- when(platform.is.win_x64, release_file "rustfmt_windows-x86_64-msvc_%s.tar.gz")
- ),
- })
- .with_receipt()
- ctx:link_bin("rustfmt", platform.is.win and "rustfmt.exe" or "rustfmt")
+ platform.when {
+ unix = function()
+ local source = github.untargz_release_file {
+ repo = "rust-lang/rustfmt",
+ asset_file = coalesce(
+ when(platform.is.mac, _.format "rustfmt_macos-x86_64_%s.tar.gz"),
+ when(platform.is.linux_x64, _.format "rustfmt_linux-x86_64_%s.tar.gz")
+ ),
+ }
+ source.with_receipt()
+ ctx:link_bin("rustfmt", path.concat { source.asset_file:gsub("%.tar%.gz$", ""), "rustfmt" })
+ end,
+ win = function()
+ local source = github.unzip_release_file {
+ repo = "rust-lang/rustfmt",
+ asset_file = coalesce(when(platform.is.win_x64, _.format "rustfmt_windows-x86_64-msvc_%s.zip")),
+ }
+ source.with_receipt()
+ ctx:link_bin("rustfmt", path.concat { source.asset_file:gsub("%.zip$", ""), "rustfmt.exe" })
+ end,
+ }
end,
}