From a686b9b456f5e80bbf386c7db6419315e2d09cef Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Tue, 28 Nov 2017 17:22:45 -0600 Subject: [PATCH] executing scripts now Signed-off-by: Kenneth Reitz --- cmd/herald-worker/main.go | 6 +++++- herald.go | 13 +++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/cmd/herald-worker/main.go b/cmd/herald-worker/main.go index 6438457..652e47f 100644 --- a/cmd/herald-worker/main.go +++ b/cmd/herald-worker/main.go @@ -4,6 +4,7 @@ import "github.com/heroku/herald" // todo: name that herlad import "time" import "log" +import "fmt" @@ -28,8 +29,11 @@ func main() { // TODO: Ensure chmod for the executable. exe.EnsureExecutable() + // Execute the executable, print the results. + fmt.Print(exe.Execute()) + // - log.Printf("Execututing '%s:%s' script…", bp, exe) + log.Printf("Executing '%s:%s' script…", bp, exe) } } diff --git a/herald.go b/herald.go index 85988ed..50951f3 100644 --- a/herald.go +++ b/herald.go @@ -8,6 +8,8 @@ import "log" import "path/filepath" import "strings" import "os" +import "os/exec" +// import "io" const BP_BRANCH = "versions" const BP_TARBALL_TEMPLATE = "https://github.com/heroku/heroku-buildpack-%s/archive/%s.zip" @@ -47,6 +49,17 @@ func (e Executable) EnsureExecutable() { } } +// Executes the given executable, and returns results. +func (e Executable) Execute() []string { + out, err := exec.Command(e.Path).Output() + if err != nil { + // TODO: Update this to return, etc. + log.Fatal(err) + } + return strings.Split(string(out), "\n") + +} + // Returns the GitHub ZipBall URI for the given buildpack. func (b Buildpack) ZipballURI() string { return fmt.Sprintf(BP_TARBALL_TEMPLATE, b.Name, BP_BRANCH)