mirror of https://github.com/folke/lazy.nvim.git
fix(health): check for errors when executing commands. Closes #1599
This commit is contained in:
parent
a9d7ade203
commit
d0921f5b9b
|
@ -37,13 +37,17 @@ function M.have(cmd, opts)
|
||||||
for _, c in ipairs(cmd) do
|
for _, c in ipairs(cmd) do
|
||||||
if vim.fn.executable(c) == 1 then
|
if vim.fn.executable(c) == 1 then
|
||||||
local version = vim.fn.system(c .. " " .. opts.version) or ""
|
local version = vim.fn.system(c .. " " .. opts.version) or ""
|
||||||
version = vim.trim(vim.split(version, "\n")[1])
|
if vim.v.shell_error ~= 0 then
|
||||||
version = version:gsub("^%s*" .. vim.pesc(c) .. "%s*", "")
|
opts.error(("failed to get version of {%s}\n%s"):format(c, version))
|
||||||
if opts.version_pattern and not version:find(opts.version_pattern, 1, true) then
|
|
||||||
opts.warn(("`%s` version `%s` needed, but found `%s`"):format(c, opts.version_pattern, version))
|
|
||||||
else
|
else
|
||||||
found = ("{%s} `%s`"):format(c, version)
|
version = vim.trim(vim.split(version, "\n")[1])
|
||||||
break
|
version = version:gsub("^%s*" .. vim.pesc(c) .. "%s*", "")
|
||||||
|
if opts.version_pattern and not version:find(opts.version_pattern, 1, true) then
|
||||||
|
opts.warn(("`%s` version `%s` needed, but found `%s`"):format(c, opts.version_pattern, version))
|
||||||
|
else
|
||||||
|
found = ("{%s} `%s`"):format(c, version)
|
||||||
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue