Skip to content

Commit

Permalink
fix sigwinch error with build constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
dwu359 committed Sep 18, 2023
1 parent c31c5e4 commit 9e998f4
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 17 deletions.
31 changes: 31 additions & 0 deletions pkg/exec_bash_cmd_any_os.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package pkg

import (
"bytes"
"fmt"
"io"
"os"
"os/exec"
"strings"

"github.com/pterm/pterm"
)

func execBashCmdAny(dir string, name string, arg ...string) string {
// Use this if the pty one doesn't work
bash_cmd := exec.Command(name, arg...)
bash_cmd.Dir = dir
pterm.DefaultHeader.WithFullWidth().Println(strings.Join(bash_cmd.Args, " "))

var stdoutBuf, stderrBuf bytes.Buffer
bash_cmd.Stdout = io.MultiWriter(os.Stdout, &stdoutBuf)
bash_cmd.Stderr = io.MultiWriter(os.Stderr, &stderrBuf)
err := bash_cmd.Run()
if err != nil {
pterm.Error.Println("Error starting cmd: ", err)
return fmt.Sprint(err)
}

outStr, errStr := string(stdoutBuf.String()), string(stderrBuf.String())
return fmt.Sprint(outStr, errStr)
}
20 changes: 3 additions & 17 deletions pkg/exec_bash_cmd.go → pkg/exec_bash_cmd_unix_os.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//go:build !windows

package pkg

import (
"bytes"
"fmt"
"io"
"os"
"os/exec"
Expand All @@ -17,22 +18,7 @@ import (

func ExecBashCmd(runtime_os string, dir string, name string, arg ...string) string {
if runtime_os == "windows" {
// Use this if the pty one doesn't work
bash_cmd := exec.Command(name, arg...)
bash_cmd.Dir = dir
pterm.DefaultHeader.WithFullWidth().Println(strings.Join(bash_cmd.Args, " "))

var stdoutBuf, stderrBuf bytes.Buffer
bash_cmd.Stdout = io.MultiWriter(os.Stdout, &stdoutBuf)
bash_cmd.Stderr = io.MultiWriter(os.Stderr, &stderrBuf)
err := bash_cmd.Run()
if err != nil {
pterm.Error.Println("Error starting cmd: ", err)
return fmt.Sprint(err)
}

outStr, errStr := string(stdoutBuf.String()), string(stderrBuf.String())
return fmt.Sprint(outStr, errStr)
execBashCmdAny(dir, name, arg...)
}
// Code below found in pty examples: https://github.com/creack/pty
bash_cmd := exec.Command(name, arg...)
Expand Down
7 changes: 7 additions & 0 deletions pkg/exec_bash_cmd_windows_os.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build windows

package pkg

func ExecBashCmd(runtime_os string, dir string, name string, arg ...string) string {
execBashCmdAny(dir, name, arg...)
}

Check failure on line 7 in pkg/exec_bash_cmd_windows_os.go

View workflow job for this annotation

GitHub Actions / goreleaser

missing return

0 comments on commit 9e998f4

Please sign in to comment.