aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-registry/index/phpcbf/init.lua
blob: 0543a83af3e313fd88b88dfb20086a7aa0c48541 (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
local Pkg = require "mason-core.package"
local _ = require "mason-core.functional"
local github = require "mason-core.managers.github"
local platform = require "mason-core.platform"
local std = require "mason-core.managers.std"

return Pkg.new {
    name = "phpcbf",
    desc = [[phpcbf automatically corrects coding standard violations that would be detected by phpcs.]],
    homepage = "https://github.com/squizlabs/PHP_CodeSniffer",
    languages = { Pkg.Lang.PHP },
    categories = { Pkg.Cat.Formatter },
    ---@async
    ---@param ctx InstallContext
    install = function(ctx)
        github
            .download_release_file({
                repo = "squizlabs/PHP_CodeSniffer",
                asset_file = "phpcbf.phar",
                out_file = platform.is.win and "phpcbf.phar" or "phpcbf",
            })
            .with_receipt()
        platform.when {
            unix = function()
                std.chmod("+x", { "phpcbf" })
                ctx:link_bin("phpcbf", "phpcbf")
            end,
            win = function()
                ctx:link_bin("phpcbf", ctx:write_php_exec_wrapper("phpcbf", "phpcbf.phar"))
            end,
        }
    end,
}