1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00
goreleaser/internal/pipeline/before/before.go
Carlos Alexandro Becker 64b1f14a86
refactor: better code organization (#757)
* refactor: merging archive in the same repo

* refactor: merging archive in the same repo

* refactor: better organizing packages

* refactor: fixing renames

* fix: new dep version

* fix: makefile

* fix: zip/tar tests

* fix: gitigonore

* fix: s3 tests

* fix: archive test
2018-08-14 23:50:20 -03:00

36 lines
725 B
Go

package before
import (
"fmt"
"os/exec"
"strings"
"github.com/apex/log"
"github.com/fatih/color"
"github.com/goreleaser/goreleaser/pkg/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:]...)
out, err := cmd.CombinedOutput()
log.Debug(string(out))
if err != nil {
return fmt.Errorf("hook failed: %s\n%v", step, string(out))
}
}
return nil
}