aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-registry/phpcs/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/mason-registry/phpcs/init.lua')
-rw-r--r--lua/mason-registry/phpcs/init.lua45
1 files changed, 45 insertions, 0 deletions
diff --git a/lua/mason-registry/phpcs/init.lua b/lua/mason-registry/phpcs/init.lua
new file mode 100644
index 00000000..17515ba2
--- /dev/null
+++ b/lua/mason-registry/phpcs/init.lua
@@ -0,0 +1,45 @@
+local Pkg = require "mason-core.package"
+local _ = require "mason-core.functional"
+local github = require "mason-core.managers.github"
+local std = require "mason-core.managers.std"
+local platform = require "mason-core.platform"
+local path = require "mason-core.path"
+
+return Pkg.new {
+ name = "phpcs",
+ desc = _.dedent [[
+ PHP_CodeSniffer(phpcs) tokenizes PHP, JavaScript and CSS files to detect violations of a defined standard.
+ ]],
+ homepage = "https://github.com/squizlabs/PHP_CodeSniffer",
+ languages = { Pkg.Lang.PHP },
+ categories = { Pkg.Cat.Linter },
+ ---@async
+ ---@param ctx InstallContext
+ install = function(ctx)
+ github
+ .download_release_file({
+ repo = "squizlabs/PHP_CodeSniffer",
+ asset_file = "phpcs.phar",
+ out_file = platform.is.win and "phpcs.phar" or "phpcs",
+ })
+ .with_receipt()
+ platform.when {
+ unix = function()
+ std.chmod("+x", { "phpcs" })
+ ctx:link_bin("phpcs", "phpcs")
+ end,
+ win = function()
+ ctx:link_bin(
+ "phpcs",
+ ctx:write_shell_exec_wrapper(
+ "phpcs",
+ ("php %q"):format(path.concat {
+ ctx.package:get_install_path(),
+ "phpcs.phar",
+ })
+ )
+ )
+ end,
+ }
+ end,
+}