LiveReloadDisabled works with Watching properly. Fixed #335.
authorspf13 <steve.francia@gmail.com>
Mon, 25 Aug 2014 17:49:53 +0000 (13:49 -0400)
committerspf13 <steve.francia@gmail.com>
Mon, 25 Aug 2014 17:49:53 +0000 (13:49 -0400)
commands/hugo.go

index 6265e998a29436870ef881a273a6e77ab3a84f26..a35a1f0017f516a77b945efef8c3eb7bbe945c73 100644 (file)
@@ -308,7 +308,7 @@ func NewWatcher(port int) error {
                for {
                        select {
                        case evs := <-watcher.Event:
-                               jww.INFO.Println(evs)
+                               jww.INFO.Println("File System Event:", evs)
 
                                static_changed := false
                                dynamic_changed := false
@@ -340,14 +340,20 @@ func NewWatcher(port int) error {
                                        fmt.Print("Static file changed, syncing\n\n")
                                        utils.StopOnErr(copyStatic(), fmt.Sprintf("Error copying static files to %s", helpers.AbsPathify(viper.GetString("PublishDir"))))
 
-                                       livereload.ForceRefresh()
+                                       if !viper.GetBool("DisableLiveReload") {
+                                               // Will block forever trying to write to a channel that nobody is reading if livereload isn't initalized
+                                               livereload.ForceRefresh()
+                                       }
                                }
 
                                if dynamic_changed {
                                        fmt.Print("Change detected, rebuilding site\n\n")
                                        utils.StopOnErr(buildSite(true))
 
-                                       livereload.ForceRefresh()
+                                       if !viper.GetBool("DisableLiveReload") {
+                                               // Will block forever trying to write to a channel that nobody is reading if livereload isn't initalized
+                                               livereload.ForceRefresh()
+                                       }
                                }
                        case err := <-watcher.Error:
                                if err != nil {