From e0e72325a4e6e6740172037584343253aa7eee5e Mon Sep 17 00:00:00 2001 From: alessio Date: Tue, 18 Oct 2016 13:38:59 +0200 Subject: [PATCH] files watcher fixed --- app/main.go | 8 ++------ cli/watcher.go | 6 +++++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/main.go b/app/main.go index df079ca..5818e16 100644 --- a/app/main.go +++ b/app/main.go @@ -107,6 +107,7 @@ func (r *realize) Wdir() string { func (r *realize) Serve(p *cli.Context) { if !p.Bool("no-server") { + fmt.Println(r.Red(r.Host) + "\n") r.Server.Open = p.Bool("open") r.Server.Start() } @@ -137,12 +138,7 @@ func (r *realize) List(p *cli.Context) error { func (r *realize) Before(p *cli.Context) error { fmt.Println(r.Blue(r.Name) + " - " + r.Blue(r.Version)) - if !p.Bool("no-server") { - fmt.Println(r.BlueS(r.Description)) - fmt.Println(r.Red(r.Host) + "\n") - } else { - fmt.Println(r.BlueS(r.Description) + "\n") - } + fmt.Println(r.BlueS(r.Description) + "\n") gopath := os.Getenv("GOPATH") if gopath == "" { log.Fatal(r.Red("$GOPATH isn't set up properly")) diff --git a/cli/watcher.go b/cli/watcher.go index 9e8cfe6..beb0ef1 100644 --- a/cli/watcher.go +++ b/cli/watcher.go @@ -20,6 +20,10 @@ func (p *Project) watching() { var wr sync.WaitGroup var watcher *fsnotify.Watcher + sync := func() { + p.parent.Sync <- "sync" + } + watcher, err := fsnotify.NewWatcher() if err != nil { log.Println(strings.ToUpper(pname(p.Name, 1)), ":", Red(err.Error())) @@ -64,7 +68,7 @@ func (p *Project) watching() { i := strings.Index(event.Name, filepath.Ext(event.Name)) if event.Name[:i] != "" && inArray(ext, p.Watcher.Exts) { p.Buffer.StdLog = append(p.Buffer.StdLog, BufferOut{Time: time.Now(), Text: strings.ToUpper(ext[1:]) + " changed " + event.Name[:i] + ext}) - p.parent.Sync <- "sync" + go sync() fmt.Println(pname(p.Name, 4), Magenta(strings.ToUpper(ext[1:])+" changed"), Magenta(event.Name[:i]+ext)) // stop and run again if p.Run {