mirror of
https://github.com/beego/bee.git
synced 2024-11-21 23:50:54 +00:00
Able to customize watch file exts
This commit is contained in:
parent
540122fdf1
commit
111bc16e19
1
bee.json
1
bee.json
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"go_install": false,
|
"go_install": false,
|
||||||
|
"watch_ext": [],
|
||||||
"dir_structure":{
|
"dir_structure":{
|
||||||
"controllers": "",
|
"controllers": "",
|
||||||
"models": "",
|
"models": "",
|
||||||
|
7
run.go
7
run.go
@ -67,8 +67,8 @@ func init() {
|
|||||||
var appname string
|
var appname string
|
||||||
var conf struct {
|
var conf struct {
|
||||||
// Indicates whether execute "go install" before "go build".
|
// 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 {
|
DirStruct struct {
|
||||||
Controllers string
|
Controllers string
|
||||||
Models string
|
Models string
|
||||||
@ -141,5 +141,8 @@ func loadConfig() error {
|
|||||||
if len(conf.DirStruct.Models) == 0 {
|
if len(conf.DirStruct.Models) == 0 {
|
||||||
conf.DirStruct.Models = "models"
|
conf.DirStruct.Models = "models"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Append watch exts.
|
||||||
|
watchExts = append(watchExts, conf.WatchExt...)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
14
watch.go
14
watch.go
@ -50,7 +50,7 @@ func NewWatcher(paths []string) {
|
|||||||
if checkTMPFile(e.Name) {
|
if checkTMPFile(e.Name) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !checkIsGoFile(e.Name) {
|
if !chekcIfWatchExt(e.Name) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,10 +178,14 @@ func checkTMPFile(name string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkIsGoFile returns true if the name HasSuffix ".go".
|
var watchExts = []string{".go"}
|
||||||
func checkIsGoFile(name string) bool {
|
|
||||||
if strings.HasSuffix(name, ".go") {
|
// chekcIfWatchExt returns true if the name HasSuffix <watch_ext>.
|
||||||
return true
|
func chekcIfWatchExt(name string) bool {
|
||||||
|
for _, s := range watchExts {
|
||||||
|
if strings.HasSuffix(name, s) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user