diff --git a/realize/projects.go b/realize/projects.go index 1033f29..6f93f2a 100644 --- a/realize/projects.go +++ b/realize/projects.go @@ -186,7 +186,10 @@ func (p *Project) Reload(path string, stop <-chan bool) { } // Go supported tools if len(path) > 0 { - fi, err := os.Stat(path) + fi, err := os.Stat(filepath.Dir(path)) + if filepath.Ext(path) == "" { + fi, err = os.Stat(path) + } if err != nil { p.Err(err) } @@ -282,7 +285,7 @@ L: for { select { case event := <-p.watcher.Events(): - if p.parent.Settings.Debug { + if p.parent.Settings.Recovery.Events { log.Println("Event:", event, "File:", event.Name, "LastFile:", p.lastFile, "Time:", time.Now(), "LastTime:", p.lastTime) } if time.Now().Truncate(time.Second).After(p.lastTime) || event.Name != p.lastFile { @@ -401,6 +404,7 @@ func (p *Project) tools(stop <-chan bool, path string, fi os.FileInfo) { go func() { for i := 0; i < v.NumField()-1; i++ { tool := v.Field(i).Interface().(Tool) + tool.parent = p if tool.Status && tool.isTool { if fi.IsDir() { if tool.dir { @@ -421,6 +425,9 @@ func (p *Project) tools(stop <-chan bool, path string, fi os.FileInfo) { return case r := <-result: if r.Err != nil { + if fi.IsDir(){ + path, _ = filepath.Abs(fi.Name()) + } msg = fmt.Sprintln(p.pname(p.Name, 2), ":", Red.Bold(r.Name), Red.Regular("there are some errors in"), ":", Magenta.Bold(path)) buff := BufferOut{Time: time.Now(), Text: "there are some errors in", Path: path, Type: r.Name, Stream: r.Err.Error()} p.stamp("error", buff, msg, r.Err.Error()) @@ -470,9 +477,9 @@ func (p *Project) walk(path string, info os.FileInfo, err error) error { if p.Validate(path, true) { result := p.watcher.Walk(path, p.init) if result != "" { - p.tools(p.stop, path, info) if info.IsDir() { // tools dir + p.tools(p.stop, path, info) p.folders++ } else { // tools files diff --git a/realize/tools.go b/realize/tools.go index ae0b36f..1e51279 100644 --- a/realize/tools.go +++ b/realize/tools.go @@ -4,6 +4,7 @@ import ( "bytes" "errors" "io/ioutil" + "log" "os/exec" "path/filepath" "strings" @@ -21,6 +22,7 @@ type Tool struct { method []string cmd []string name string + parent *Project } // Tools go @@ -117,6 +119,9 @@ func (t *Tool) Exec(path string, stop <-chan bool) (response Response) { path = filepath.Dir(path) } if s := ext(path); s == "" || s == "go" { + if t.parent.parent.Settings.Recovery.Tools { + log.Println("Tool:", t.name, path, args) + } var out, stderr bytes.Buffer done := make(chan error) args = append(t.cmd, args...)