From 06db7d7bf711a3a625007444ae1b719da3b64821 Mon Sep 17 00:00:00 2001 From: Kyle Boyle Date: Sat, 24 Jan 2015 15:58:44 -0400 Subject: [PATCH 1/7] Add option to individually specify watch path and path to buildable package -e path/to/package --- lib/builder.go | 7 ++++--- main.go | 17 ++++++++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/builder.go b/lib/builder.go index 0181812..392ddb5 100644 --- a/lib/builder.go +++ b/lib/builder.go @@ -14,13 +14,14 @@ type Builder interface { } type builder struct { + execdir string dir string binary string errors string useGodep bool } -func NewBuilder(dir string, bin string, useGodep bool) Builder { +func NewBuilder(execdir string, dir string, bin string, useGodep bool) Builder { if len(bin) == 0 { bin = "bin" } @@ -32,7 +33,7 @@ func NewBuilder(dir string, bin string, useGodep bool) Builder { } } - return &builder{dir: dir, binary: bin, useGodep: useGodep} + return &builder{execdir: execdir, dir: dir, binary: bin, useGodep: useGodep} } func (b *builder) Binary() string { @@ -50,7 +51,7 @@ func (b *builder) Build() error { } else { command = exec.Command("go", "build", "-o", b.binary) } - command.Dir = b.dir + command.Dir = b.execdir output, err := command.CombinedOutput() diff --git a/main.go b/main.go index e9310a0..aa9611c 100644 --- a/main.go +++ b/main.go @@ -6,7 +6,7 @@ import ( "github.com/codegangsta/cli" "github.com/codegangsta/envy/lib" - "github.com/codegangsta/gin/lib" + "github.com/kyleboyle/gin/lib" "log" "os" @@ -50,6 +50,11 @@ func main() { Value: ".", Usage: "Path to watch files from", }, + cli.StringFlag{ + Name: "execpath,e", + Value: "", + Usage: "Path to package that contains buildable artifact", + }, cli.BoolFlag{ Name: "immediate,i", Usage: "run the server immediately after it's built", @@ -82,6 +87,11 @@ func MainAction(c *cli.Context) { appPort := strconv.Itoa(c.GlobalInt("appPort")) immediate = c.GlobalBool("immediate") + execpath := c.GlobalString("execpath") + if len(execpath) == 0 { + c.GlobalString("path") + } + // Bootstrap the environment envy.Bootstrap() @@ -93,8 +103,8 @@ func MainAction(c *cli.Context) { logger.Fatal(err) } - builder := gin.NewBuilder(c.GlobalString("path"), c.GlobalString("bin"), c.GlobalBool("godep")) - runner := gin.NewRunner(filepath.Join(wd, builder.Binary()), c.Args()...) + builder := gin.NewBuilder(execpath, c.GlobalString("path"), c.GlobalString("bin"), c.GlobalBool("godep")) + runner := gin.NewRunner(filepath.Join(wd, execpath, builder.Binary()), c.Args()...) runner.SetWriter(os.Stdout) proxy := gin.NewProxy(builder, runner) @@ -170,6 +180,7 @@ func scanChanges(watchPath string, cb scanCallback) { } if filepath.Ext(path) == ".go" && info.ModTime().After(startTime) { + log.Printf("%s", path) cb(path) startTime = time.Now() return errors.New("done") From 3fa6795197408ffeec1494db11db6ed76e621dd4 Mon Sep 17 00:00:00 2001 From: Kyle Boyle Date: Sat, 24 Jan 2015 18:22:14 -0400 Subject: [PATCH 2/7] use origin import path --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index aa9611c..0b53494 100644 --- a/main.go +++ b/main.go @@ -6,7 +6,7 @@ import ( "github.com/codegangsta/cli" "github.com/codegangsta/envy/lib" - "github.com/kyleboyle/gin/lib" + "github.com/codegangsta/gin/lib" "log" "os" From 7a6f309b532c61f9074125af4b542c7e52a4ea4c Mon Sep 17 00:00:00 2001 From: Kyle Boyle Date: Sat, 24 Jan 2015 18:35:50 -0400 Subject: [PATCH 3/7] fix test --- lib/builder_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/builder_test.go b/lib/builder_test.go index 73d039e..b782c08 100644 --- a/lib/builder_test.go +++ b/lib/builder_test.go @@ -15,7 +15,7 @@ func Test_Builder_Build_Success(t *testing.T) { bin += ".exe" } - builder := gin.NewBuilder(wd, bin, false) + builder := gin.NewBuilder(wd, wd, bin, false) err := builder.Build() expect(t, err, nil) From a818c5e37d92a55e32a895a755516d5bb17536f1 Mon Sep 17 00:00:00 2001 From: Kyle Boyle Date: Sat, 24 Jan 2015 15:58:44 -0400 Subject: [PATCH 4/7] Add option to individually specify watch path and path to buildable package -e path/to/package --- lib/builder.go | 1 - main.go | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/builder.go b/lib/builder.go index 392ddb5..3f16f0b 100644 --- a/lib/builder.go +++ b/lib/builder.go @@ -35,7 +35,6 @@ func NewBuilder(execdir string, dir string, bin string, useGodep bool) Builder { return &builder{execdir: execdir, dir: dir, binary: bin, useGodep: useGodep} } - func (b *builder) Binary() string { return b.binary } diff --git a/main.go b/main.go index 0b53494..cb7dbad 100644 --- a/main.go +++ b/main.go @@ -4,9 +4,9 @@ import ( "errors" "fmt" - "github.com/codegangsta/cli" "github.com/codegangsta/envy/lib" "github.com/codegangsta/gin/lib" + "gopkg.in/urfave/cli.v1" "log" "os" From a2300d8f6605d6f611f168b50f8197e9032baf22 Mon Sep 17 00:00:00 2001 From: Kyle Boyle Date: Sat, 24 Jan 2015 18:22:14 -0400 Subject: [PATCH 5/7] use origin import path --- main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index cb7dbad..67b5d20 100644 --- a/main.go +++ b/main.go @@ -4,9 +4,10 @@ import ( "errors" "fmt" + cli "gopkg.in/urfave/cli.v1" + "github.com/codegangsta/envy/lib" "github.com/codegangsta/gin/lib" - "gopkg.in/urfave/cli.v1" "log" "os" From ae2e6688c933d00c5801ffac5ca0b2078110e912 Mon Sep 17 00:00:00 2001 From: Manuel Alonso Date: Wed, 9 Nov 2016 18:59:24 +0100 Subject: [PATCH 6/7] reverting removed line --- lib/builder.go | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/builder.go b/lib/builder.go index 3f16f0b..392ddb5 100644 --- a/lib/builder.go +++ b/lib/builder.go @@ -35,6 +35,7 @@ func NewBuilder(execdir string, dir string, bin string, useGodep bool) Builder { return &builder{execdir: execdir, dir: dir, binary: bin, useGodep: useGodep} } + func (b *builder) Binary() string { return b.binary } From eb1a16b911ae1a8b9cd1ec9d0784bcfee13d83e4 Mon Sep 17 00:00:00 2001 From: Manuel Alonso Date: Wed, 9 Nov 2016 19:02:45 +0100 Subject: [PATCH 7/7] reverting to cli of codegansgta --- main.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/main.go b/main.go index 67b5d20..0b53494 100644 --- a/main.go +++ b/main.go @@ -4,8 +4,7 @@ import ( "errors" "fmt" - cli "gopkg.in/urfave/cli.v1" - + "github.com/codegangsta/cli" "github.com/codegangsta/envy/lib" "github.com/codegangsta/gin/lib"