mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-20 13:26:45 +00:00
fix(process): deal with process errors
This commit is contained in:
parent
332a7ff9b3
commit
a75d950b8f
2 changed files with 14 additions and 8 deletions
|
@ -42,8 +42,8 @@ function Process.new(cmd, opts)
|
|||
opts = opts or {}
|
||||
opts.args = opts.args or {}
|
||||
if type(cmd) == "table" then
|
||||
self.cmd = table.remove(cmd, 1)
|
||||
vim.list_extend(opts.args, cmd)
|
||||
self.cmd = cmd[1]
|
||||
vim.list_extend(opts.args, vim.list_slice(cmd, 2))
|
||||
else
|
||||
self.cmd = cmd
|
||||
end
|
||||
|
@ -233,10 +233,7 @@ function M.exec(cmd, opts)
|
|||
opts = opts or {}
|
||||
local proc = M.spawn(cmd, opts)
|
||||
proc:wait()
|
||||
if proc.code ~= 0 then
|
||||
error("Process failed with code " .. proc.code)
|
||||
end
|
||||
return vim.split(proc.data, "\n")
|
||||
return vim.split(proc.data, "\n"), proc.code
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue