Skip to content

Commit

Permalink
Return script output on error (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrynhard authored Jun 5, 2017
1 parent 426abe1 commit 81055ed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 4 additions & 0 deletions conform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions conform/enforce.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 81055ed

Please sign in to comment.