fix(runner): now it returns output correctly
This commit is contained in:
parent
16b9a5c8f4
commit
4e80f30cb3
1 changed files with 6 additions and 4 deletions
|
|
@ -2,7 +2,7 @@ local Job = require "plenary.job"
|
|||
local runner = {}
|
||||
|
||||
---@class gopher.RunnerOpts
|
||||
---@field args string[]
|
||||
---@field args? string[]
|
||||
---@field cwd? string?
|
||||
---@field on_exit? fun(data:string, status:number)
|
||||
|
||||
|
|
@ -10,15 +10,17 @@ local runner = {}
|
|||
---@param opts gopher.RunnerOpts
|
||||
---@return string
|
||||
function runner.sync(cmd, opts)
|
||||
local output
|
||||
local output = ""
|
||||
Job:new({
|
||||
command = cmd,
|
||||
args = opts.args,
|
||||
cwd = opts.cwd,
|
||||
on_exit = function(data, status)
|
||||
output = data:result()
|
||||
vim.schedule(function()
|
||||
output = data:result()
|
||||
opts.on_exit(output, status)
|
||||
if opts.on_exit then
|
||||
opts.on_exit(output, status)
|
||||
end
|
||||
end)
|
||||
end,
|
||||
}):sync()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue