Skip to content

Commit

Permalink
feat(util): utility method to get sync process output
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Dec 21, 2022
1 parent 3c3a711 commit e95da35
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lua/lazy/manage/process.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,22 @@ function M.spawn(cmd, opts)
return handle
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

0 comments on commit e95da35

Please sign in to comment.