mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 18:58:12 +00:00
fix(util.spawn): correctly mark as faild on abort
This commit is contained in:
parent
9f0aa20489
commit
6917597f6d
1 changed files with 9 additions and 2 deletions
|
@ -57,13 +57,17 @@ end
|
|||
function Proc:kill(signal)
|
||||
close(self.stdout)
|
||||
close(self.stderr)
|
||||
if self:running() then
|
||||
if not self.handle then
|
||||
self.aborted = true
|
||||
elseif self:running() then
|
||||
self.handle:kill(signal or "sigterm")
|
||||
end
|
||||
end
|
||||
|
||||
function Proc:failed()
|
||||
if self.aborted then
|
||||
return true
|
||||
end
|
||||
if self:running() then
|
||||
return false
|
||||
end
|
||||
|
@ -98,6 +102,9 @@ end
|
|||
|
||||
function Proc:run()
|
||||
assert(not self.handle, "already running")
|
||||
if self.aborted then
|
||||
return self:on_exit()
|
||||
end
|
||||
self.stdout = assert(uv.new_pipe())
|
||||
self.stderr = assert(uv.new_pipe())
|
||||
self.data = { [self.stdout] = {}, [self.stderr] = {} }
|
||||
|
@ -179,7 +186,7 @@ function Proc:on_exit()
|
|||
close(self.stdout)
|
||||
close(self.stderr)
|
||||
if self.opts.on_exit then
|
||||
self.opts.on_exit(self, self.code ~= 0 or self.signal ~= 0)
|
||||
self.opts.on_exit(self, self.code ~= 0 or self.signal ~= 0 or self.aborted or false)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue