Skip to content

Commit

Permalink
code: Always display the output of code blocks
Browse files Browse the repository at this point in the history
Any output that is printed may still be useful even if the command returns
an error so lets display it. Printing out even in case of error is fine,
if there's no output and output.Write handles that fine. I tested this by
trying to run a code block for a language I do not have the compiler for.
  • Loading branch information
mmlb committed Sep 17, 2022
1 parent f9b0cda commit 92be922
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions internal/code/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,9 @@ func Execute(code Block) Result {
// execute and write output
cmd := exec.Command(command[0], command[1:]...)
out, err := cmd.Output()
output.Write(out)
if err != nil {
output.Write([]byte(err.Error()))
} else {
output.Write(out)
}

// update status code
Expand Down

0 comments on commit 92be922

Please sign in to comment.