handle empty exports gracefully; log in DEBUG level

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I9c9914b380cb3fd7f7b7a73cba1e19a76a6a6964
This commit is contained in:
raf 2026-01-27 10:02:14 +03:00
commit b07302cc27
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF

View file

@ -237,7 +237,18 @@ M._init = function(path)
end end
vim.schedule(function() vim.schedule(function()
local ok, env = pcall(vim.json.decode, obj.stdout) local stdout = obj.stdout or ""
if stdout == "" then
-- direnv exported no changes; nothing to do
notify(
"direnv export produced no output (no changes)",
vim.log.levels.DEBUG
)
return
end
local ok, env = pcall(vim.json.decode, stdout)
if not ok or type(env) ~= "table" then if not ok or type(env) ~= "table" then
notify("Failed to parse direnv JSON output", vim.log.levels.ERROR) notify("Failed to parse direnv JSON output", vim.log.levels.ERROR)