Skip to content

Commit

Permalink
fix(scripts): only process if not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
gorillamoe committed Oct 4, 2024
1 parent 67447c2 commit 10d6323
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lua/kulala/parser/scripts/engines/javascript/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,17 @@ local generate_all = function(script_type, scripts_data)
return scripts
end

local scripts_is_empty = function(scripts_data)
return #scripts_data.inline == 0 and #scripts_data.files == 0
end

---@param type "pre_request_client_only" | "pre_request" | "post_request_client_only" | "post_request" -- type of script
---@param data ScriptData
M.run = function(type, data)
if scripts_is_empty(data) then
return
end

if not NODE_EXISTS then
Logger.error("node not found, please install nodejs")
return
Expand All @@ -112,7 +120,7 @@ M.run = function(type, data)
end

local scripts = generate_all(type, data)
if scripts == nil then
if #scripts == 0 then
return
end

Expand Down

0 comments on commit 10d6323

Please sign in to comment.