From a797cec30964619bea0c228593268af0fd471a60 Mon Sep 17 00:00:00 2001 From: Marco Kellershoff Date: Wed, 21 Aug 2024 02:15:56 +0200 Subject: [PATCH] fix(scripts): node_modules path local to script.cwd --- lua/kulala/scripts/javascript.lua | 12 +++++++++++- lua/kulala/utils/fs.lua | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lua/kulala/scripts/javascript.lua b/lua/kulala/scripts/javascript.lua index d202111..5a22718 100644 --- a/lua/kulala/scripts/javascript.lua +++ b/lua/kulala/scripts/javascript.lua @@ -76,7 +76,17 @@ M.run = function(type, data) end for _, script in ipairs(scripts) do - vim.system({ "node", script.path }, { cwd = script.cwd }):wait() + vim + .system({ + "node", + script.path, + }, { + cwd = script.cwd, + env = { + NODE_PATH = script.cwd .. "/" .. "node_modules", + }, + }) + :wait() end end diff --git a/lua/kulala/utils/fs.lua b/lua/kulala/utils/fs.lua index 7717d97..19da9cc 100644 --- a/lua/kulala/utils/fs.lua +++ b/lua/kulala/utils/fs.lua @@ -158,7 +158,7 @@ end M.get_global_scripts_variables = function() local fp = M.get_global_scripts_variables_file_path() if M.file_exists(fp) then - return vim.fn.json_decode(fp) + return vim.fn.json_decode(M.read_file(fp)) end return nil end