grafana/pkg/build/exec.go
Kevin Minehart d913e46e37
Chore: move build command to importable package (#38726)
* move build command to importable package & clean up
2021-09-03 11:24:21 -05:00

35 lines
737 B
Go

package build
import (
"bytes"
"log"
"os"
"os/exec"
"strings"
)
func runError(cmd string, args ...string) ([]byte, error) {
// Can ignore gosec G204 because this function is not used in Grafana, only in the build process.
//nolint:gosec
ecmd := exec.Command(cmd, args...)
bs, err := ecmd.CombinedOutput()
if err != nil {
return nil, err
}
return bytes.TrimSpace(bs), nil
}
func runPrint(cmd string, args ...string) {
log.Println(cmd, strings.Join(args, " "))
// Can ignore gosec G204 because this function is not used in Grafana, only in the build process.
//nolint:gosec
ecmd := exec.Command(cmd, args...)
ecmd.Stdout = os.Stdout
ecmd.Stderr = os.Stderr
err := ecmd.Run()
if err != nil {
log.Fatal(err)
}
}