diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0d12a92 --- /dev/null +++ b/.gitignore @@ -0,0 +1,30 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe +*.test +*.prof + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# vim +*.swp diff --git a/webhook.go b/webhook.go index f5528e9..4b6d14f 100644 --- a/webhook.go +++ b/webhook.go @@ -8,6 +8,8 @@ import ( "os" "os/exec" "strings" + "bytes" + "fmt" ) // -------------------------------------------------------------------------------- @@ -49,12 +51,19 @@ var cfg Config func runScript(item *WatchItem) (err error) { script := "./" + item.Script - out, err := exec.Command("bash", "-c", script).Output() + cmd := exec.Command("bash", "-c", script) + + var out bytes.Buffer + var stderr bytes.Buffer + cmd.Stdout = &out + cmd.Stderr = &stderr + err = cmd.Run() + if err != nil { - log.Printf("Exec command failed: %s\n", err) + fmt.Println("Exec command failed, " + fmt.Sprint(err) + ": " + stderr.String()) } - log.Printf("Run %s output: %s\n", script, string(out)) + log.Printf("Run %s output: %s\n", script, out.String()) return }