From 4281cbfa34f879954c021dd81616daf0879bc7a7 Mon Sep 17 00:00:00 2001 From: spf13 Date: Mon, 25 Aug 2014 13:49:53 -0400 Subject: [PATCH] LiveReloadDisabled works with Watching properly. Fixed #335. --- commands/hugo.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/commands/hugo.go b/commands/hugo.go index 6265e998a..a35a1f001 100644 --- a/commands/hugo.go +++ b/commands/hugo.go @@ -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 {