From 446d7c8071bda2b7d22e5eec2de43edf08ebbb1e Mon Sep 17 00:00:00 2001 From: alessio Date: Wed, 3 Aug 2016 18:49:37 +0200 Subject: [PATCH] added build and install in watcher --- realize/watcher.go | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/realize/watcher.go b/realize/watcher.go index 0a96cf8..a3c29f4 100644 --- a/realize/watcher.go +++ b/realize/watcher.go @@ -20,6 +20,26 @@ type Watcher struct{ Preview bool `yaml:"preview,omitempty"` } +func (p *Project) install(){ + if p.Bin { + if err := p.GoInstall(); err != nil{ + Fail(err.Error()) + }else{ + Success(p.Name + ": Installed") + } + } +} + +func (p *Project) build(){ + if p.Build { + if err := p.GoBuild(); err != nil{ + Fail(err.Error()) + }else{ + Success(p.Name + ": Builded") + } + } +} + func (p *Project) Watching(){ var watcher *fsnotify.Watcher @@ -43,8 +63,11 @@ func (p *Project) Watching(){ return nil } - // run, bin, build - p.GoBuild() + // run go build + go p.build() + + // run go install + p.install() p.reload = time.Now().Truncate(time.Second) @@ -74,7 +97,13 @@ func (p *Project) Watching(){ if _, err := os.Stat(event.Name); err == nil { i := strings.Index(event.Name, filepath.Ext(event.Name)) log.Println(green(p.Name+":")+"\t", event.Name[:i]) - // run, bin, build + + // run go build + go p.build() + + // run go install + p.install() + p.reload = time.Now().Truncate(time.Second) } }