From 0c9d42e996df9524da99d3766b53f3920262e7a7 Mon Sep 17 00:00:00 2001 From: alessio Date: Mon, 24 Apr 2017 02:07:37 +0200 Subject: [PATCH] tools fixed --- watcher/cmd.go | 4 ++-- watcher/exec.go | 2 +- watcher/watcher.go | 13 ++++++------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/watcher/cmd.go b/watcher/cmd.go index a8edf6e..a67d6e7 100644 --- a/watcher/cmd.go +++ b/watcher/cmd.go @@ -44,8 +44,8 @@ func (h *Blueprint) Run() error { tools.Vet = tool{ status: &h.Projects[k].Cmds.Vet, cmd: "go", - options: []string{"test"}, - name: "Go Test", + options: []string{"vet"}, + name: "Go Vet", } } h.Projects[k].tools = tools diff --git a/watcher/exec.go b/watcher/exec.go index 72a6d27..fcad084 100644 --- a/watcher/exec.go +++ b/watcher/exec.go @@ -4,7 +4,6 @@ import ( "bufio" "bytes" "fmt" - "github.com/tockins/realize/style" "log" "os" "os/exec" @@ -12,6 +11,7 @@ import ( "strings" "sync" "time" + "github.com/tockins/realize/style" ) // GoRun is an implementation of the bin execution diff --git a/watcher/watcher.go b/watcher/watcher.go index d3880c5..dbf6f5b 100644 --- a/watcher/watcher.go +++ b/watcher/watcher.go @@ -3,19 +3,19 @@ package watcher import ( "errors" "fmt" - "github.com/fsnotify/fsnotify" - "github.com/tockins/realize/style" "log" "math/big" "os" "os/signal" "path/filepath" - "reflect" "strconv" "strings" "sync" "syscall" "time" + "reflect" + "github.com/fsnotify/fsnotify" + "github.com/tockins/realize/style" ) var msg string @@ -79,7 +79,7 @@ func (p *Project) watchByPolling() { p.cmd("change") p.tool(file, p.tools.Fmt) - p.tool(path, p.tools.Vet) + p.tool(file, p.tools.Vet) p.tool(path, p.tools.Test) p.tool(path, p.tools.Generate) go p.routines(channel, &wr) @@ -285,9 +285,8 @@ func (p *Project) build() error { func (p *Project) tool(path string, tool tool) error { if tool.status != nil { v := reflect.ValueOf(tool.status).Elem() - if v.Interface().(bool) && strings.HasSuffix(path, ".go") { - options := append(tool.options, path) - if stream, err := p.goTools(p.base, tool.cmd, options...); err != nil { + if v.Interface().(bool) && (strings.HasSuffix(path, ".go") || strings.HasSuffix(path, "")) { + if stream, err := p.goTools(path, tool.cmd, tool.options...); err != nil { msg = fmt.Sprintln(p.pname(p.Name, 2), ":", style.Red.Bold(tool.name), style.Red.Regular("there are some errors in"), ":", style.Magenta.Bold(path)) out = BufferOut{Time: time.Now(), Text: "there are some errors in", Path: path, Type: tool.name, Stream: stream} p.print("error", out, msg, stream)