diff options
| author | William Boman <william@redwill.se> | 2023-03-12 08:21:15 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-12 08:21:15 +0100 |
| commit | a01d02ad7f680aec98a1e2ec35b04cedd307cfa8 (patch) | |
| tree | 1a09e274a1f2a4da85b911abcbb182a211035501 /lua/mason-core/installer/managers/luarocks.lua | |
| parent | feat(golangci-lint): support linux_arm64 (#1089) (diff) | |
| download | mason-a01d02ad7f680aec98a1e2ec35b04cedd307cfa8.tar mason-a01d02ad7f680aec98a1e2ec35b04cedd307cfa8.tar.gz mason-a01d02ad7f680aec98a1e2ec35b04cedd307cfa8.tar.bz2 mason-a01d02ad7f680aec98a1e2ec35b04cedd307cfa8.tar.lz mason-a01d02ad7f680aec98a1e2ec35b04cedd307cfa8.tar.xz mason-a01d02ad7f680aec98a1e2ec35b04cedd307cfa8.tar.zst mason-a01d02ad7f680aec98a1e2ec35b04cedd307cfa8.zip | |
feat: add github registry source capabilities (#1091)
Diffstat (limited to 'lua/mason-core/installer/managers/luarocks.lua')
| -rw-r--r-- | lua/mason-core/installer/managers/luarocks.lua | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lua/mason-core/installer/managers/luarocks.lua b/lua/mason-core/installer/managers/luarocks.lua new file mode 100644 index 00000000..7f636e2b --- /dev/null +++ b/lua/mason-core/installer/managers/luarocks.lua @@ -0,0 +1,40 @@ +local Result = require "mason-core.result" +local _ = require "mason-core.functional" +local installer = require "mason-core.installer" +local log = require "mason-core.log" +local platform = require "mason-core.platform" +local path = require "mason-core.path" + +local M = {} + +---@async +---@param pkg string +---@param version string +---@param opts { server?: string, dev?: boolean } +function M.install(pkg, version, opts) + opts = opts or {} + log.fmt_debug("luarocks: install %s %s %s", pkg, version, opts) + local ctx = installer.context() + ctx:promote_cwd() -- luarocks encodes absolute paths during installation + return ctx.spawn.luarocks { + "install", + { "--tree", ctx.cwd:get() }, + opts.dev and "--dev" or vim.NIL, + opts.server and ("--server=%s"):format(opts.server) or vim.NIL, + { pkg, version }, + } +end + +---@param exec string +function M.bin_path(exec) + return Result.pcall(platform.when, { + unix = function() + return path.concat { "bin", exec } + end, + win = function() + return path.concat { "bin", ("%s.bat"):format(exec) } + end, + }) +end + +return M |
