From 800a2420263d09c64da1a0788400f3ed9f4535f8 Mon Sep 17 00:00:00 2001 From: Stuart Innes Date: Wed, 28 Jun 2017 15:31:35 +0100 Subject: [PATCH] Allow users to specify a build target directory - useful if for example you have a web service mixed in with other buildable code --- cmd/init.go | 1 + refresh/config.go | 1 + refresh/manager.go | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/init.go b/cmd/init.go index 15a2586..40a3612 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -19,6 +19,7 @@ var initCmd = &cobra.Command{ AppRoot: ".", IgnoredFolders: []string{"vendor", "log", "logs", "tmp", "node_modules", "bin", "templates"}, IncludedExtensions: []string{".go"}, + BuildTargetPath: "", BuildPath: os.TempDir(), BuildDelay: 200, BinaryName: "refresh-build", diff --git a/refresh/config.go b/refresh/config.go index cf0d1e9..7b93d92 100644 --- a/refresh/config.go +++ b/refresh/config.go @@ -17,6 +17,7 @@ type Configuration struct { AppRoot string `yaml:"app_root"` IgnoredFolders []string `yaml:"ignored_folders"` IncludedExtensions []string `yaml:"included_extensions"` + BuildTargetPath string `yaml:"build_target_path"` BuildPath string `yaml:"build_path"` BuildDelay time.Duration `yaml:"build_delay"` BinaryName string `yaml:"binary_name"` diff --git a/refresh/manager.go b/refresh/manager.go index eb821e0..8bec1ef 100644 --- a/refresh/manager.go +++ b/refresh/manager.go @@ -83,7 +83,7 @@ func (r *Manager) build(event fsnotify.Event) { now := time.Now() r.Logger.Print("Rebuild on: %s", event.Name) - cmd := exec.Command("go", "build", "-v", "-i", "-o", r.FullBuildPath()) + cmd := exec.Command("go", "build", "-v", "-i", "-o", r.FullBuildPath(), r.Configuration.BuildTargetPath) err := r.runAndListen(cmd) if err != nil { if strings.Contains(err.Error(), "no buildable Go source files") {