aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-registry/index/stylua/init.lua
blob: 59adff44e21d9c6306a5c828a11e306dc97c39ea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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 coalesce, when = _.coalesce, _.when

return Pkg.new {
    name = "stylua",
    desc = [[An opinionated Lua code formatter]],
    homepage = "https://github.com/JohnnyMorganz/StyLua",
    languages = { Pkg.Lang.Lua, Pkg.Lang.Luau },
    categories = { Pkg.Cat.Formatter },
    ---@async
    ---@param ctx InstallContext
    install = function(ctx)
        github
            .unzip_release_file({
                repo = "johnnymorganz/stylua",
                asset_file = coalesce(
                    when(platform.is.mac_arm64, "stylua-macos-aarch64.zip"),
                    when(platform.is.mac_x64, "stylua-macos.zip"),
                    when(platform.is.linux_x64, "stylua-linux-x86_64.zip"),
                    when(platform.is.linux_arm64, "stylua-linux-aarch64.zip"),
                    when(platform.is.win_x64, "stylua-win64.zip")
                ),
            })
            .with_receipt()
        ctx:link_bin("stylua", platform.is.win and "stylua.exe" or "stylua")
    end,
}