Skip to content

Commit fe4165a

Browse files
committed
fix: last line is never sent
Signed-off-by: Yoan Blanc <[email protected]>
1 parent a151197 commit fe4165a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cmd.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ func (c *Cmd) run() {
326326
// who's waiting for us to close them.
327327
if c.stdoutStream != nil {
328328
defer func() {
329+
c.stdoutStream.Flush()
330+
c.stderrStream.Flush()
329331
// exec.Cmd.Wait has already waited for all output:
330332
// Otherwise, during the execution of the command a separate goroutine
331333
// reads from the process over a pipe and delivers that data to the
@@ -635,3 +637,11 @@ func (rw *OutputStream) SetLineBufferSize(n int) {
635637
rw.bufSize = n
636638
rw.buf = make([]byte, rw.bufSize)
637639
}
640+
641+
// Flush empties the buffer of its last line.
642+
func (rw *OutputStream) Flush() {
643+
if rw.lastChar > 0 {
644+
line := string(rw.buf[0:rw.lastChar])
645+
rw.streamChan <- line
646+
}
647+
}

0 commit comments

Comments
 (0)