Skip to content

Commit 73615ce

Browse files
authored
fix: error when package.json is invalid (#48)
1 parent fc076a3 commit 73615ce

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lua/js-i18n/utils.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ function M.detect_library(workspace_dir)
2727
return nil
2828
end
2929

30-
local package = vim.fn.json_decode(package_json)
31-
if package == nil then
30+
local ok, package = pcall(vim.fn.json_decode, package_json)
31+
32+
if not ok or package == nil then
3233
return nil
3334
end
3435

0 commit comments

Comments
 (0)