mirror of https://github.com/folke/lazy.nvim.git
feat(util): utility method to get sync process output
This commit is contained in:
parent
3c3a711dda
commit
e95da35d09
|
@ -108,4 +108,22 @@ function M.spawn(cmd, opts)
|
||||||
return handle
|
return handle
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param cmd string[]
|
||||||
|
---@param opts? {cwd:string}
|
||||||
|
function M.exec(cmd, opts)
|
||||||
|
opts = opts or {}
|
||||||
|
---@type string[]
|
||||||
|
local lines
|
||||||
|
local job = vim.fn.jobstart(cmd, {
|
||||||
|
cwd = opts.cwd,
|
||||||
|
pty = false,
|
||||||
|
stdout_buffered = true,
|
||||||
|
on_stdout = function(_, _lines)
|
||||||
|
lines = _lines
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
vim.fn.jobwait({ job })
|
||||||
|
return lines
|
||||||
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
Loading…
Reference in New Issue