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
54
55
56
57
58
59
60
61
62
63
64
|
local process = require "mason-core.process"
local installer = require "mason-core.installer"
local _ = require "mason-core.functional"
local platform = require "mason-core.platform"
local M = {}
local create_bin_path = _.if_else(_.always(platform.is.win), _.format "%s.exe", _.identity)
---@param package string
local function with_receipt(package)
return function()
local ctx = installer.context()
ctx.receipt:with_primary_source(ctx.receipt.dotnet(package))
end
end
---@async
---@param pkg string
---@param opt { bin: string[] | nil } | nil
function M.package(pkg, opt)
return function()
return M.install(pkg, opt).with_receipt()
end
end
---@async
---@param pkg string
---@param opt { bin: string[] | nil } | nil
function M.install(pkg, opt)
local ctx = installer.context()
ctx.spawn.dotnet {
"tool",
"update",
"--tool-path",
".",
ctx.requested_version
:map(function(version)
return { "--version", version }
end)
:or_else(vim.NIL),
pkg,
}
if opt and opt.bin then
if opt.bin then
_.each(function(executable)
ctx:link_bin(executable, create_bin_path(executable))
end, opt.bin)
end
end
return {
with_receipt = with_receipt(pkg),
}
end
function M.env(root_dir)
return {
PATH = process.extend_path { root_dir },
}
end
return M
|