Chore: move build command to importable package (#38726)

* move build command to importable package & clean up
This commit is contained in:
Kevin Minehart
2021-09-03 11:24:21 -05:00
committed by GitHub
parent 68c7d054bf
commit d913e46e37
8 changed files with 602 additions and 464 deletions
+34
View File
@@ -0,0 +1,34 @@
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)
}
}