aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-09-14 17:58:11 +0200
committerGitHub <noreply@github.com>2022-09-14 17:58:11 +0200
commitd39e46db31c9b2eee458ca59a814ebc4fe8a5bd5 (patch)
treecac215882f0692cd2e181944210e768a32d23a58 /lua
parentfix(r-languageserver): use github releases as version source (#417) (diff)
downloadmason-d39e46db31c9b2eee458ca59a814ebc4fe8a5bd5.tar
mason-d39e46db31c9b2eee458ca59a814ebc4fe8a5bd5.tar.gz
mason-d39e46db31c9b2eee458ca59a814ebc4fe8a5bd5.tar.bz2
mason-d39e46db31c9b2eee458ca59a814ebc4fe8a5bd5.tar.lz
mason-d39e46db31c9b2eee458ca59a814ebc4fe8a5bd5.tar.xz
mason-d39e46db31c9b2eee458ca59a814ebc4fe8a5bd5.tar.zst
mason-d39e46db31c9b2eee458ca59a814ebc4fe8a5bd5.zip
refactor: store link state in install context object (#419)
Diffstat (limited to 'lua')
-rw-r--r--lua/mason-core/installer/context.lua7
-rw-r--r--lua/mason-core/installer/linker.lua3
2 files changed, 8 insertions, 2 deletions
diff --git a/lua/mason-core/installer/context.lua b/lua/mason-core/installer/context.lua
index 7d0a505b..50850219 100644
--- a/lua/mason-core/installer/context.lua
+++ b/lua/mason-core/installer/context.lua
@@ -141,6 +141,7 @@ end
---@field public package Package
---@field public cwd CwdManager
---@field public stdio_sink StdioSink
+---@field private bin_links table<string, string>
local InstallContext = {}
InstallContext.__index = InstallContext
@@ -160,6 +161,7 @@ function InstallContext.new(handle, opts)
receipt = receipt.InstallReceiptBuilder.new(),
requested_version = Optional.of_nilable(opts.requested_version),
stdio_sink = handle.stdio.sink,
+ bin_links = {},
}, InstallContext)
end
@@ -310,8 +312,11 @@ function InstallContext:write_shell_exec_wrapper(new_executable_rel_path, comman
}
end
+---@param executable string
+---@param rel_path string
function InstallContext:link_bin(executable, rel_path)
- self.receipt:with_link("bin", executable, rel_path)
+ self.bin_links[executable] = rel_path
+ return self
end
return InstallContext
diff --git a/lua/mason-core/installer/linker.lua b/lua/mason-core/installer/linker.lua
index 0419f392..a1cc53d0 100644
--- a/lua/mason-core/installer/linker.lua
+++ b/lua/mason-core/installer/linker.lua
@@ -33,7 +33,7 @@ end
---@async
---@param context InstallContext
local function link_bin(context)
- local links = context.receipt.links.bin
+ local links = context.bin_links
local pkg = context.package
for name, rel_path in pairs(links) do
local target_abs_path = path.concat { pkg:get_install_path(), rel_path }
@@ -71,6 +71,7 @@ local function link_bin(context)
)
end,
}
+ context.receipt:with_link("bin", name, rel_path)
end
end