mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
fix: simplified before hook code
This commit is contained in:
parent
cbdd90ddad
commit
cac92e8734
@ -5,6 +5,8 @@ import (
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/fatih/color"
|
||||
"github.com/goreleaser/goreleaser/context"
|
||||
)
|
||||
|
||||
@ -13,15 +15,7 @@ type Pipe struct{}
|
||||
|
||||
// String is the name of this pipe
|
||||
func (Pipe) String() string {
|
||||
return "Run global hooks before starting the relase process"
|
||||
}
|
||||
|
||||
// Default initialized the default values
|
||||
func (Pipe) Default(ctx *context.Context) error {
|
||||
if ctx.Config.Before.Hooks == nil {
|
||||
ctx.Config.Before.Hooks = []string{}
|
||||
}
|
||||
return nil
|
||||
return "Running before hooks"
|
||||
}
|
||||
|
||||
// Run executes the hooks
|
||||
@ -29,8 +23,10 @@ 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))
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user