aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-core/spawn.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/mason-core/spawn.lua')
-rw-r--r--lua/mason-core/spawn.lua16
1 files changed, 16 insertions, 0 deletions
diff --git a/lua/mason-core/spawn.lua b/lua/mason-core/spawn.lua
index 3c9c645d..78be4fd7 100644
--- a/lua/mason-core/spawn.lua
+++ b/lua/mason-core/spawn.lua
@@ -4,6 +4,7 @@ local a = require "mason-core.async"
local log = require "mason-core.log"
local platform = require "mason-core.platform"
local process = require "mason-core.process"
+local settings = require "mason.settings"
local is_not_nil = _.complement(_.equals(vim.NIL))
@@ -64,6 +65,7 @@ local get_path_from_env_list =
---@field stdio_sink StdioSink? If provided, will be used to write to stdout and stderr.
---@field cwd string?
---@field on_spawn (fun(handle: luv_handle, stdio: luv_pipe[], pid: integer))? Will be called when the process successfully spawns.
+---@field firewall boolean?
setmetatable(spawn, {
---@param canonical_cmd string
@@ -102,6 +104,20 @@ setmetatable(spawn, {
end
end
+ if args.firewall and settings.current.firewall.enabled then
+ a.scheduler()
+ table.insert(spawn_args.args, 1, cmd)
+ local expanded_cmd = exepath(
+ "sfw",
+ settings.current.firewall.auto_managed and vim.fn.expand "$MASON/opt/mason/system/bin" or nil
+ )
+ if expanded_cmd == "" then
+ return Failure({ stderr = "Failed to find sfw (Socket Firewall) in PATH." }, "sfw")
+ else
+ cmd = expanded_cmd
+ end
+ end
+
local _, exit_code, signal = a.wait(function(resolve)
local handle, stdio, pid = process.spawn(cmd, spawn_args, resolve)
if args.on_spawn and handle and stdio and pid then