Cmd prints stdout and sterr
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

This commit is contained in:
Marvin Steadfast 2021-06-14 20:07:16 +02:00
parent b5182bfb9c
commit fffbad8a44
2 changed files with 5 additions and 1 deletions

View File

@ -2,7 +2,7 @@
project_name: "don" project_name: "don"
gitea_urls: gitea_urls:
api: https://git.xsfx.dev/api/v1 api: https://git.xsfx.dev/api/v1/
builds: builds:
- main: ./cmd - main: ./cmd

4
don.go
View File

@ -5,6 +5,7 @@ package don
import ( import (
"errors" "errors"
"os"
"os/exec" "os/exec"
"time" "time"
@ -18,6 +19,9 @@ var errTimeout = errors.New("timeout")
func Cmd(c string) func() bool { func Cmd(c string) func() bool {
return func() bool { return func() bool {
cmd := exec.Command("sh", "-c", c) cmd := exec.Command("sh", "-c", c)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
log.Warn().Err(err).Msg("cmd has error") log.Warn().Err(err).Msg("cmd has error")