Skip to content

Commit c9f2354

Browse files
committed
let json be an optional dependency
if user `cmake -Bbuild -DGENERATE_LUADOCS=OFF`, `require"json"` is not necessary
1 parent e37e3a3 commit c9f2354

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

git2.nobj.lua

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,15 @@ subfiles {
8585
--
8686
-- Load parsed libgit2 docs.
8787
--
88-
local json = require"json"
8988
local file = io.open("docs/libgit2.json", "r")
90-
local libgit2_docs = json.decode(file:read("*a"))
89+
local text = file:read("*a")
9190
file:close()
92-
93-
local lg_funcs = libgit2_docs.functions
91+
local ok, json = pcall(require, "json")
92+
local lg_funcs = {}
93+
if ok then
94+
local libgit2_docs = json.decode(text)
95+
lg_funcs = libgit2_docs.functions
96+
end
9497

9598
-- Copy docs from libgit2
9699
reg_stage_parser("pre_gen",{

0 commit comments

Comments
 (0)