Skip to content

Commit

Permalink
Removing sub-command CombinedOutput (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmiranda authored Dec 3, 2021
1 parent 1b31681 commit 4feb0c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions cfdtunnel/cfdtunnel.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cfdtunnel

import (
"fmt"
"os"
"os/exec"
"strings"
Expand Down Expand Up @@ -100,10 +99,14 @@ func (args Arguments) runSubCommand(tunnelConfig TunnelConfig) {
}

cmd := subCommand{exec.Command(args.Command, args.Args...)}

cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

cmd.setupEnvironmentVariables(tunnelConfig.envVars)
output, err := cmd.CombinedOutput()

fmt.Println(string(output))
err := cmd.Run()

if err != nil {
log.Errorf("An error occurred trying to run the command %v: %v", args.Command, err)
Expand Down
2 changes: 1 addition & 1 deletion cfdtunnel/cfdtunnel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func TestRunSubCommandStdOut(t *testing.T) {
out, _ := ioutil.ReadAll(r)
os.Stdout = rescueStdout

assert.Equal(t, "cfdtunnel.go\n\n", string(out))
assert.Equal(t, "cfdtunnel.go\n", string(out))
}

func TestRunSubCommandMissing(t *testing.T) {
Expand Down

0 comments on commit 4feb0c4

Please sign in to comment.