aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-registry/index/quick-lint-js/init.lua
blob: 3aa515d8c6b14c31c57d193d04633271f838a67a (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
43
44
45
46
47
48
49
50
51
52
53
local Pkg = require "mason-core.package"
local _ = require "mason-core.functional"
local github = require "mason-core.managers.github"
local path = require "mason-core.path"
local platform = require "mason-core.platform"
local std = require "mason-core.managers.std"

local coalesce, when = _.coalesce, _.when

return Pkg.new {
    name = "quick-lint-js",
    desc = _.dedent [[
        Over 130× faster than ESLint, quick-lint-js gives you instant feedback as you code. Find bugs in your JavaScript
        before your finger leaves the keyboard. Lint any JavaScript file with no configuration.
    ]],
    homepage = "https://quick-lint-js.com/",
    languages = { Pkg.Lang.JavaScript },
    categories = { Pkg.Cat.LSP, Pkg.Cat.Linter },
    ---@async
    ---@param ctx InstallContext
    install = function(ctx)
        local repo = "quick-lint/quick-lint-js"
        local release_file = assert(
            coalesce(
                when(platform.is.mac_x64, "macos.tar.gz"),
                when(platform.is.mac_arm64, "macos-aarch64.tar.gz"),
                when(platform.is.linux_x64, "linux.tar.gz"),
                when(platform.is.linux_arm64, "linux-aarch64.tar.gz"),
                when(platform.is.linux_arm, "linux-armhf.tar.gz"),
                when(platform.is.win_x64, "windows.zip"),
                when(platform.is.win_arm64, "windows-arm64.zip"),
                when(platform.is.win_arm, "windows-arm.zip")
            ),
            "Current platform is not supported."
        )

        local source = github.tag { repo = repo }
        source.with_receipt()

        local url = ("https://c.quick-lint-js.com/releases/%s/manual/%s"):format(source.tag, release_file)
        platform.when {
            unix = function()
                std.download_file(url, "archive.tar.gz")
                std.untar("archive.tar.gz", { strip_components = 1 })
            end,
            win = function()
                std.download_file(url, "archive.zip")
                std.unzip("archive.zip", ".")
            end,
        }
        ctx:link_bin("quick-lint-js", path.concat { "bin", platform.is.win and "quick-lint-js.exe" or "quick-lint-js" })
    end,
}