From 3f15b69bcc9f98c6689605ce905583f1d2b05770 Mon Sep 17 00:00:00 2001 From: Faissal Elamraoui Date: Sun, 22 Jan 2017 22:28:52 +0100 Subject: [PATCH] Send a reload message when AutoBuild is triggered --- watch.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/watch.go b/watch.go index fd75645..aaa6eec 100644 --- a/watch.go +++ b/watch.go @@ -51,7 +51,7 @@ func NewWatcher(paths []string, files []string, isgenerate bool) { if shouldIgnoreFile(e.Name) { continue } - if !checkIfWatchExt(e.Name) { + if !shouldWatchFileWithExtension(e.Name) { continue } @@ -75,8 +75,11 @@ func NewWatcher(paths []string, files []string, isgenerate bool) { } return } - AutoBuild(files, isgenerate) + + if conf.EnableReload { + sendReload(e.String()) + } }() } case err := <-watcher.Errors: @@ -93,7 +96,6 @@ func NewWatcher(paths []string, files []string, isgenerate bool) { logger.Fatalf("Failed to watch directory: %s", err) } } - } // getFileModTime returns unix timestamp of `os.File.ModTime` for the given path. @@ -267,8 +269,9 @@ var ignoredFilesRegExps = []string{ `(\w+).tmp`, } -// checkIfWatchExt returns true if the name HasSuffix . -func checkIfWatchExt(name string) bool { +// shouldWatchFileWithExtension returns true if the name of the file +// hash a suffix that should be watched. +func shouldWatchFileWithExtension(name string) bool { for _, s := range watchExts { if strings.HasSuffix(name, s) { return true