aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2023-04-26 17:58:27 +0200
committerGitHub <noreply@github.com>2023-04-26 17:58:27 +0200
commit1cb07e4d7bba61a5da9502bb2a6a1d1ff278d5fe (patch)
tree3722db95c89c079fc63e166cdfab26cfab400479
parentrefactor(linker): copy_file instead of rename on Windows (#1254) (diff)
downloadmason-1cb07e4d7bba61a5da9502bb2a6a1d1ff278d5fe.tar
mason-1cb07e4d7bba61a5da9502bb2a6a1d1ff278d5fe.tar.gz
mason-1cb07e4d7bba61a5da9502bb2a6a1d1ff278d5fe.tar.bz2
mason-1cb07e4d7bba61a5da9502bb2a6a1d1ff278d5fe.tar.lz
mason-1cb07e4d7bba61a5da9502bb2a6a1d1ff278d5fe.tar.xz
mason-1cb07e4d7bba61a5da9502bb2a6a1d1ff278d5fe.tar.zst
mason-1cb07e4d7bba61a5da9502bb2a6a1d1ff278d5fe.zip
feat(linker): add ruby exec wrapper delegate (#1260)
-rw-r--r--lua/mason-core/installer/context.lua15
-rw-r--r--lua/mason-core/installer/registry/expr.lua4
-rw-r--r--lua/mason-core/installer/registry/link.lua10
3 files changed, 26 insertions, 3 deletions
diff --git a/lua/mason-core/installer/context.lua b/lua/mason-core/installer/context.lua
index 10f6629f..e42393ff 100644
--- a/lua/mason-core/installer/context.lua
+++ b/lua/mason-core/installer/context.lua
@@ -254,6 +254,21 @@ function InstallContext:write_node_exec_wrapper(new_executable_rel_path, script_
end
---@param new_executable_rel_path string Relative path to the executable file to create.
+---@param script_rel_path string Relative path to the Node.js script.
+function InstallContext:write_ruby_exec_wrapper(new_executable_rel_path, script_rel_path)
+ if not self.fs:file_exists(script_rel_path) then
+ error(("Cannot write Ruby exec wrapper for path %q as it doesn't exist."):format(script_rel_path), 0)
+ end
+ return self:write_shell_exec_wrapper(
+ new_executable_rel_path,
+ ("ruby %q"):format(path.concat {
+ self.package:get_install_path(),
+ script_rel_path,
+ })
+ )
+end
+
+---@param new_executable_rel_path string Relative path to the executable file to create.
---@param script_rel_path string Relative path to the PHP script.
function InstallContext:write_php_exec_wrapper(new_executable_rel_path, script_rel_path)
if not self.fs:file_exists(script_rel_path) then
diff --git a/lua/mason-core/installer/registry/expr.lua b/lua/mason-core/installer/registry/expr.lua
index ad7cfd43..a07fc00d 100644
--- a/lua/mason-core/installer/registry/expr.lua
+++ b/lua/mason-core/installer/registry/expr.lua
@@ -1,5 +1,6 @@
local Result = require "mason-core.result"
local _ = require "mason-core.functional"
+local platform = require "mason-core.platform"
local M = {}
@@ -40,6 +41,9 @@ local FILTERS = {
take_if_not = take_if_not,
to_lower = _.to_lower,
to_upper = _.to_upper,
+ is_platform = function(target)
+ return platform.is[target]
+ end,
}
---@generic T : table
diff --git a/lua/mason-core/installer/registry/link.lua b/lua/mason-core/installer/registry/link.lua
index 76741112..108c4233 100644
--- a/lua/mason-core/installer/registry/link.lua
+++ b/lua/mason-core/installer/registry/link.lua
@@ -79,6 +79,13 @@ local bin_delegates = {
return ctx:write_node_exec_wrapper(bin, target)
end)
end,
+ ["ruby"] = function(target, bin)
+ local installer = require "mason-core.installer"
+ local ctx = installer.context()
+ return Result.pcall(function()
+ return ctx:write_ruby_exec_wrapper(bin, target)
+ end)
+ end,
["exec"] = function(target, bin)
local installer = require "mason-core.installer"
local ctx = installer.context()
@@ -152,9 +159,6 @@ local function expand_bin(ctx, spec, purl, source)
local expr_ctx = {
version = purl.version,
source = source,
- is_platform = function(target)
- return platform.is[target]
- end,
}
local bin_table = spec.bin