aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-registry/index/php-cs-fixer/init.lua
blob: b70741f7bf486653fcfd577413e3af53977475b3 (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
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 = "php-cs-fixer",
    desc = _.dedent [[
        The PHP Coding Standards Fixer (PHP CS Fixer) tool fixes your code to follow standards; whether you want to
        follow PHP coding standards as defined in the PSR-1, PSR-2, etc., or other community driven ones like the
        Symfony one. You can also define your (team's) style through configuration.')
    ]],
    homepage = "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer",
    languages = { Pkg.Lang.PHP },
    categories = { Pkg.Cat.Formatter },
    ---@async
    ---@param ctx InstallContext
    install = function(ctx)
        github
            .download_release_file({
                repo = "PHP-CS-Fixer/PHP-CS-Fixer",
                asset_file = "php-cs-fixer.phar",
                out_file = platform.is.win and "php-cs-fixer.phar" or "php-cs-fixer",
            })
            .with_receipt()
        platform.when {
            unix = function()
                std.chmod("+x", { "php-cs-fixer" })
                ctx:link_bin("php-cs-fixer", "php-cs-fixer")
            end,
            win = function()
                ctx:link_bin("php-cs-fixer", ctx:write_php_exec_wrapper("php-cs-fixer", "php-cs-fixer.phar"))
            end,
        }
    end,
}