Skip to content

Commit

Permalink
fix: error when package.json is invalid (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
nabekou29 authored Dec 14, 2024
1 parent fc076a3 commit 73615ce
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lua/js-i18n/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ function M.detect_library(workspace_dir)
return nil
end

local package = vim.fn.json_decode(package_json)
if package == nil then
local ok, package = pcall(vim.fn.json_decode, package_json)

if not ok or package == nil then
return nil
end

Expand Down

0 comments on commit 73615ce

Please sign in to comment.