diff --git a/bee.json b/bee.json index f24d27c..4665137 100644 --- a/bee.json +++ b/bee.json @@ -1,5 +1,6 @@ { "go_install": false, + "watch_ext": [], "dir_structure":{ "controllers": "", "models": "", diff --git a/run.go b/run.go index 7b657b5..edc1f33 100644 --- a/run.go +++ b/run.go @@ -67,8 +67,8 @@ func init() { var appname string var conf struct { // Indicates whether execute "go install" before "go build". - GoInstall bool `json:"go_install"` - + GoInstall bool `json:"go_install"` + WatchExt []string `json:"watch_ext"` DirStruct struct { Controllers string Models string @@ -141,5 +141,8 @@ func loadConfig() error { if len(conf.DirStruct.Models) == 0 { conf.DirStruct.Models = "models" } + + // Append watch exts. + watchExts = append(watchExts, conf.WatchExt...) return nil } diff --git a/watch.go b/watch.go index f0f23f2..a10b013 100644 --- a/watch.go +++ b/watch.go @@ -50,7 +50,7 @@ func NewWatcher(paths []string) { if checkTMPFile(e.Name) { continue } - if !checkIsGoFile(e.Name) { + if !chekcIfWatchExt(e.Name) { continue } @@ -178,10 +178,14 @@ func checkTMPFile(name string) bool { return false } -// checkIsGoFile returns true if the name HasSuffix ".go". -func checkIsGoFile(name string) bool { - if strings.HasSuffix(name, ".go") { - return true +var watchExts = []string{".go"} + +// chekcIfWatchExt returns true if the name HasSuffix . +func chekcIfWatchExt(name string) bool { + for _, s := range watchExts { + if strings.HasSuffix(name, s) { + return true + } } return false }