Skip to content

Commit

Permalink
fix!(api.command): stop collect if flow was completed
Browse files Browse the repository at this point in the history
collect now accepts the flow
  • Loading branch information
danielefongo committed Apr 23, 2024
1 parent ccd88e8 commit 08da32a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions lua/microscope/api/command.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,14 @@ function command:into(flow)
self:close(true)
end

function command:collect()
function command:collect(flow)
local outputs = ""
for shell_out in self:get_iter() do
if flow.stopped() then
self:close()
end
outputs = outputs .. shell_out
coroutine.yield("")
flow.write("")
end
self:close(true)

Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ To consume the command, you can run:
```lua
local my_echo_result = cmd
.shell("echo", { "-n", "hello\nworld" }, cwd)
:collect()
:collect(flow)
```

- `into`: push results into the flow.
Expand Down

0 comments on commit 08da32a

Please sign in to comment.