Skip to content

Commit

Permalink
refactor(api.command): move read_start into spawn
Browse files Browse the repository at this point in the history
  • Loading branch information
danielefongo committed Apr 10, 2024
1 parent 866ec20 commit 430376e
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions lua/microscope/api/command.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ function command:spawn(last)
}, function()
self:close()
end)

if last then
uv.read_start(self.output_stream, function(_, data)
if data then
self.output = self.output .. data
end
end)
end
else
local previous_output = function() end
if self.input then
Expand Down Expand Up @@ -69,18 +77,6 @@ function command:spawn(last)
end
end

function command:read_start()
if self.input then
self.input:read_start()
end

uv.read_start(self.output_stream, function(_, data)
if data then
self.output = self.output .. data
end
end)
end

function command:get_consumer()
return function()
if self.handle and self.handle:is_active() and not self.output:find("\n") then
Expand All @@ -97,7 +93,6 @@ end

function command:get_iter()
self:spawn(true)
self:read_start()

return self:get_consumer()
end
Expand Down

0 comments on commit 430376e

Please sign in to comment.