Skip to content

Commit

Permalink
files watcher fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
asoseil committed Oct 18, 2016
1 parent d139177 commit e0e7232
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 2 additions & 6 deletions app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down Expand Up @@ -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"))
Expand Down
6 changes: 5 additions & 1 deletion cli/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit e0e7232

Please sign in to comment.