Skip to content

Commit

Permalink
fix(typescript): protect against malformed or empty package.json (#307)
Browse files Browse the repository at this point in the history
  • Loading branch information
mehalter authored Jun 23, 2023
1 parent 8ac4492 commit 9bf02e1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lua/astrocommunity/pack/typescript/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ local function check_json_key_exists(filename, key)
file:close()

-- Parse the JSON content
local json = vim.fn.json_decode(content)
if type(json) ~= "table" then
local json_parsed, json = pcall(vim.fn.json_decode, content)
if not json_parsed or type(json) ~= "table" then
return false -- Invalid JSON format
end

Expand Down

0 comments on commit 9bf02e1

Please sign in to comment.