1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00
goreleaser/pipeline/before/before.go
2018-04-03 21:35:48 -03:00

35 lines
721 B
Go

package before
import (
"fmt"
"os/exec"
"strings"
"github.com/apex/log"
"github.com/fatih/color"
"github.com/goreleaser/goreleaser/context"
)
// Pipe is a global hook pipe
type Pipe struct{}
// String is the name of this pipe
func (Pipe) String() string {
return "Running before hooks"
}
// Run executes the hooks
func (Pipe) Run(ctx *context.Context) error {
/* #nosec */
for _, step := range ctx.Config.Before.Hooks {
args := strings.Fields(step)
log.Infof("running %s", color.CyanString(step))
cmd := exec.Command(args[0], args[1:]...)
if out, err := cmd.CombinedOutput(); err != nil {
log.Debug(string(out))
return fmt.Errorf("hook failed: %s\n%v", step, string(out))
}
}
return nil
}