Skip to content

Commit

Permalink
checkpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Ortel <[email protected]>
  • Loading branch information
jortel committed Dec 9, 2023
1 parent f9e4b02 commit 8583ea2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion command/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (r *Command) Run() (err error) {
// The command and output are both reported in
// task Report.Activity.
func (r *Command) RunWith(ctx context.Context) (err error) {
r.Writer.reporter = r.Reporter
r.Writer.reporter = &r.Reporter
r.Reporter.Run(r.Path, r.Options)
defer func() {
r.Writer.End()
Expand Down
5 changes: 4 additions & 1 deletion command/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ func (r *Reporter) Output(buffer []byte, delimited bool) {
case Error:
case Default:
case LiveOutput:
if r.index >= len(buffer) {
return
}
batch := string(buffer[r.index:])
if delimited {
end := strings.LastIndex(batch, "\n")
Expand All @@ -108,7 +111,7 @@ func (r *Reporter) Output(buffer []byte, delimited bool) {
} else {
output := r.Filter(batch)
addon.Activity("> %s", output)
r.index += len(batch)
r.index = len(buffer)
}
}
}
2 changes: 1 addition & 1 deletion command/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type ByteFilter func(in []byte) (out []byte)
// Writer records command output.
type Writer struct {
Filter ByteFilter
reporter Reporter
reporter *Reporter
buffer []byte
end chan any
ended chan any
Expand Down

0 comments on commit 8583ea2

Please sign in to comment.