aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-registry/shellcheck/init.lua
blob: 634e42f123e5d202f72b961dd29a3d0b0dc5af0d (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
32
33
34
35
36
37
38
39
40
41
42
local Pkg = require "mason.core.package"
local _ = require "mason.core.functional"
local github = require "mason.core.managers.github"
local platform = require "mason.core.platform"

return Pkg.new {
    name = "shellcheck",
    desc = [[ShellCheck, a static analysis tool for shell scripts]],
    homepage = "https://www.shellcheck.net/",
    categories = { Pkg.Cat.Linter },
    languages = { Pkg.Lang.Bash },
    ---@async
    ---@param ctx InstallContext
    install = function(ctx)
        platform.when {
            unix = function()
                github
                    .untarxz_release_file({
                        strip_components = 1,
                        repo = "koalaman/shellcheck",
                        asset_file = _.coalesce(
                            _.when(platform.is.mac, _.format "shellcheck-%s.darwin.x86_64.tar.xz"),
                            _.when(platform.is.linux_x64, _.format "shellcheck-%s.linux.x86_64.tar.xz"),
                            _.when(platform.is.linux_arm64, _.format "shellcheck-%s.linux.aarch64.tar.xz"),
                            _.when(platform.is.linux_arm, _.format "shellcheck-%s.linux.armv6hf.tar.xz")
                        ),
                    })
                    .with_receipt()
                ctx:link_bin("shellcheck", "shellcheck")
            end,
            win = function()
                github
                    .unzip_release_file({
                        repo = "koalaman/shellcheck",
                        asset_file = _.coalesce(_.when(platform.is.win_x64, _.format "shellcheck-%s.zip")),
                    })
                    .with_receipt()
                ctx:link_bin("shellcheck", "shellcheck.exe")
            end,
        }
    end,
}