chore(build): streaming logs (#512)
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
parent
b48b6b7afd
commit
5fde5e03ea
@ -67,23 +67,25 @@ M.build = function(opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---@type integer
|
---@type integer
|
||||||
local code
|
local pid
|
||||||
vim.system(cmd, {
|
local exit_code = { 0 }
|
||||||
text = true,
|
|
||||||
stdout = function(_, data)
|
local ok, job_or_err = pcall(vim.system, cmd, { text = true }, function(obj)
|
||||||
if data then vim.schedule(function() vim.api.nvim_echo({ { data, "Normal" } }, false, {}) end) end
|
local stderr = obj.stderr and vim.split(obj.stderr, "\n") or {}
|
||||||
end,
|
local stdout = obj.stdout and vim.split(obj.stdout, "\n") or {}
|
||||||
stderr = function(err, _)
|
if vim.tbl_contains(exit_code, obj.code) then
|
||||||
if err then vim.schedule(function() vim.api.nvim_echo({ { err, "ErrorMsg" } }, false, {}) end) end
|
local output = stdout
|
||||||
end,
|
if #output == 0 then
|
||||||
}, function(obj)
|
table.insert(output, "")
|
||||||
if vim.tbl_contains({ 0 }, obj.code) then
|
Utils.info("outputs: " .. output)
|
||||||
code = obj.code
|
|
||||||
else
|
else
|
||||||
vim.api.nvim_echo({ { "Build failed with exit code: " .. obj.code, "ErrorMsg" } }, false, {})
|
Utils.error("error: " .. stderr)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
return code
|
if not ok then Utils.error("Failed to build the command: " .. cmd .. "\n" .. job_or_err, { once = true }) end
|
||||||
|
pid = job_or_err.pid
|
||||||
|
return pid
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param question? string
|
---@param question? string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user