mirror of
https://github.com/beego/bee.git
synced 2024-11-22 10:10:53 +00:00
Send a reload message when AutoBuild is triggered
This commit is contained in:
parent
de62ae6043
commit
3f15b69bcc
13
watch.go
13
watch.go
@ -51,7 +51,7 @@ func NewWatcher(paths []string, files []string, isgenerate bool) {
|
|||||||
if shouldIgnoreFile(e.Name) {
|
if shouldIgnoreFile(e.Name) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !checkIfWatchExt(e.Name) {
|
if !shouldWatchFileWithExtension(e.Name) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,8 +75,11 @@ func NewWatcher(paths []string, files []string, isgenerate bool) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoBuild(files, isgenerate)
|
AutoBuild(files, isgenerate)
|
||||||
|
|
||||||
|
if conf.EnableReload {
|
||||||
|
sendReload(e.String())
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
case err := <-watcher.Errors:
|
case err := <-watcher.Errors:
|
||||||
@ -93,7 +96,6 @@ func NewWatcher(paths []string, files []string, isgenerate bool) {
|
|||||||
logger.Fatalf("Failed to watch directory: %s", err)
|
logger.Fatalf("Failed to watch directory: %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// getFileModTime returns unix timestamp of `os.File.ModTime` for the given path.
|
// getFileModTime returns unix timestamp of `os.File.ModTime` for the given path.
|
||||||
@ -267,8 +269,9 @@ var ignoredFilesRegExps = []string{
|
|||||||
`(\w+).tmp`,
|
`(\w+).tmp`,
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkIfWatchExt returns true if the name HasSuffix <watch_ext>.
|
// shouldWatchFileWithExtension returns true if the name of the file
|
||||||
func checkIfWatchExt(name string) bool {
|
// hash a suffix that should be watched.
|
||||||
|
func shouldWatchFileWithExtension(name string) bool {
|
||||||
for _, s := range watchExts {
|
for _, s := range watchExts {
|
||||||
if strings.HasSuffix(name, s) {
|
if strings.HasSuffix(name, s) {
|
||||||
return true
|
return true
|
||||||
|
Loading…
Reference in New Issue
Block a user