Skip to content
This repository was archived by the owner on Sep 18, 2021. It is now read-only.

Commit 5cf48c0

Browse files
committed
fix(cli): show actual error message that caused abort
1 parent 3f26361 commit 5cf48c0

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

routines/exec.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
// Exec is a wrapper function around exec.Command with additional settings for this CLI
1616
func Exec(name string, arg ...string) error {
1717
cmd := exec.Command(name, arg...)
18+
var outBuffer = new(bytes.Buffer)
1819
var errBuffer = new(bytes.Buffer)
1920
if viper.GetBool("verbose") {
2021
_, err := fmt.Fprintf(os.Stdout, "Executing command: %s\n", strings.Join(append([]string{name}, arg...), " "))
@@ -24,10 +25,19 @@ func Exec(name string, arg ...string) error {
2425
cmd.Stdout = os.Stdout
2526
cmd.Stderr = os.Stdout
2627
} else {
28+
cmd.Stdout = outBuffer
2729
cmd.Stderr = errBuffer
2830
}
2931
if err := cmd.Run(); err != nil {
30-
return fmt.Errorf(errBuffer.String())
32+
lines := strings.Split(outBuffer.String(), "\n")
33+
filtered := []string{errBuffer.String()}
34+
for _, x := range lines {
35+
if strings.HasPrefix(x, "fatal:") {
36+
filtered = append(filtered, x)
37+
}
38+
}
39+
40+
return fmt.Errorf(strings.Join(filtered, "\n"))
3141
}
3242
return nil
3343
}

0 commit comments

Comments
 (0)