1
0
mirror of https://github.com/beego/bee.git synced 2024-11-25 20:10:55 +00:00

Send a reload message when AutoBuild is triggered

This commit is contained in:
Faissal Elamraoui 2017-01-22 22:28:52 +01:00
parent de62ae6043
commit 3f15b69bcc

View File

@ -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