From 81055ed01af331bf8d5c5596cf8dfe26f608e532 Mon Sep 17 00:00:00 2001 From: Andrew Rynhard Date: Sun, 4 Jun 2017 18:48:55 -0700 Subject: [PATCH] Return script output on error (#3) --- conform.yaml | 4 ++++ conform/enforce.go | 8 ++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/conform.yaml b/conform.yaml index 86eaf74b..9ece369c 100644 --- a/conform.yaml +++ b/conform.yaml @@ -50,6 +50,10 @@ scripts: fi clean: | + #!/bin/bash + + set -e + cat .gitignore | while read line; do rm -rf "$line"; done dep ensure dep prune diff --git a/conform/enforce.go b/conform/enforce.go index e9a9a20e..dbaec10d 100644 --- a/conform/enforce.go +++ b/conform/enforce.go @@ -123,13 +123,9 @@ func (e *Enforcer) ExtractArtifact(artifact string) error { func (e *Enforcer) ExecuteScript(script string) error { if s, ok := e.config.Scripts[script]; ok { log.Printf("Running %s script", script) - command := exec.Command("bash", "-c", s) - command.Stdout = os.Stdout - command.Stderr = os.Stderr - command.Start() - err := command.Wait() + out, err := exec.Command("bash", "-c", s).Output() if err != nil { - return err + return fmt.Errorf("Failed executing %s: %v\n%s", script, err, out) } return nil