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 = {}
|
local runner = {}
|
||||||
|
|
||||||
---@class gopher.RunnerOpts
|
---@class gopher.RunnerOpts
|
||||||
---@field args string[]
|
---@field args? string[]
|
||||||
---@field cwd? string?
|
---@field cwd? string?
|
||||||
---@field on_exit? fun(data:string, status:number)
|
---@field on_exit? fun(data:string, status:number)
|
||||||
|
|
||||||
|
|
@ -10,15 +10,17 @@ local runner = {}
|
||||||
---@param opts gopher.RunnerOpts
|
---@param opts gopher.RunnerOpts
|
||||||
---@return string
|
---@return string
|
||||||
function runner.sync(cmd, opts)
|
function runner.sync(cmd, opts)
|
||||||
local output
|
local output = ""
|
||||||
Job:new({
|
Job:new({
|
||||||
command = cmd,
|
command = cmd,
|
||||||
args = opts.args,
|
args = opts.args,
|
||||||
cwd = opts.cwd,
|
cwd = opts.cwd,
|
||||||
on_exit = function(data, status)
|
on_exit = function(data, status)
|
||||||
vim.schedule(function()
|
|
||||||
output = data:result()
|
output = data:result()
|
||||||
|
vim.schedule(function()
|
||||||
|
if opts.on_exit then
|
||||||
opts.on_exit(output, status)
|
opts.on_exit(output, status)
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
end,
|
end,
|
||||||
}):sync()
|
}):sync()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue