From 4ce841397e3ea68241b025836084d4350366d96d Mon Sep 17 00:00:00 2001 From: Marco Kellershoff Date: Thu, 7 Nov 2024 19:57:43 +0100 Subject: [PATCH] fix(scripts): windows: js engine build and run This is a workaround for a bug/weird behaviour in neovim: https://github.com/neovim/neovim/issues/31107 Once this has been merged: https://github.com/neovim/neovim/pull/31109 We can revert this workaround. Fixes #304 --- lua/kulala/globals/init.lua | 2 +- lua/kulala/parser/scripts/engines/javascript/init.lua | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lua/kulala/globals/init.lua b/lua/kulala/globals/init.lua index 3d0dd46..5382eba 100644 --- a/lua/kulala/globals/init.lua +++ b/lua/kulala/globals/init.lua @@ -4,7 +4,7 @@ local M = {} local plugin_tmp_dir = FS.get_plugin_tmp_dir() -M.VERSION = "4.4.0" +M.VERSION = "4.4.1" M.UI_ID = "kulala://ui" M.SCRATCHPAD_ID = "kulala://scratchpad" M.HEADERS_FILE = plugin_tmp_dir .. "/headers.txt" diff --git a/lua/kulala/parser/scripts/engines/javascript/init.lua b/lua/kulala/parser/scripts/engines/javascript/init.lua index ef3212f..1df8d87 100644 --- a/lua/kulala/parser/scripts/engines/javascript/init.lua +++ b/lua/kulala/parser/scripts/engines/javascript/init.lua @@ -6,6 +6,8 @@ local M = {} local NPM_EXISTS = vim.fn.executable("npm") == 1 local NODE_EXISTS = vim.fn.executable("node") == 1 +local NPM_BIN = vim.fn.exepath("npm") +local NODE_BIN = vim.fn.exepath("node") local SCRIPTS_DIR = FS.get_scripts_dir() local REQUEST_SCRIPTS_DIR = FS.get_request_scripts_dir() local SCRIPTS_BUILD_DIR = FS.get_tmp_scripts_build_dir() @@ -23,12 +25,12 @@ local FILE_MAPPING = { M.install = function() FS.copy_dir(BASE_DIR, SCRIPTS_BUILD_DIR) - local res_install = vim.system({ "npm", "install", "--prefix", SCRIPTS_BUILD_DIR }):wait() + local res_install = vim.system({ NPM_BIN, "install", "--prefix", SCRIPTS_BUILD_DIR }):wait() if res_install.code ~= 0 then Logger.error("npm install fail with code " .. res_install.code) return end - local res_build = vim.system({ "npm", "run", "build", "--prefix", SCRIPTS_BUILD_DIR }):wait() + local res_build = vim.system({ NPM_BIN, "run", "build", "--prefix", SCRIPTS_BUILD_DIR }):wait() if res_build.code ~= 0 then Logger.error("npm run build fail with code " .. res_build.code) return @@ -135,7 +137,7 @@ M.run = function(type, data) for _, script in ipairs(scripts) do local output = vim .system({ - "node", + NODE_BIN, script.path, }, { cwd = script.cwd,