diff --git a/commands/hugo.go b/commands/hugo.go index 84fe42f76..5ee3f7385 100644 --- a/commands/hugo.go +++ b/commands/hugo.go @@ -90,7 +90,8 @@ func isUserError(err error) bool { return userErrorRegexp.MatchString(err.Error()) } -//HugoCmd is Hugo's root command. Every other command attached to HugoCmd is a child command to it. +// HugoCmd is Hugo's root command. +// Every other command attached to HugoCmd is a child command to it. var HugoCmd = &cobra.Command{ Use: "hugo", Short: "hugo builds your site", @@ -105,10 +106,12 @@ Complete documentation is available at http://gohugo.io/.`, return err } - watchConfig() + if BuildWatch { + viper.Set("DisableLiveReload", true) + watchConfig() + } return build() - }, } @@ -412,7 +415,7 @@ func watchConfig() { fmt.Println("Config file changed:", e.Name) utils.CheckErr(buildSite(true)) if !viper.GetBool("DisableLiveReload") { - // Will block forever trying to write to a channel that nobody is reading if livereload isn't initalized + // Will block forever trying to write to a channel that nobody is reading if livereload isn't initialized livereload.ForceRefresh() } }) @@ -777,7 +780,7 @@ func NewWatcher(port int) error { } if !BuildWatch && !viper.GetBool("DisableLiveReload") { - // Will block forever trying to write to a channel that nobody is reading if livereload isn't initalized + // Will block forever trying to write to a channel that nobody is reading if livereload isn't initialized // force refresh when more than one file if len(staticEvents) > 0 { @@ -800,7 +803,7 @@ func NewWatcher(port int) error { rebuildSite(dynamicEvents) if !BuildWatch && !viper.GetBool("DisableLiveReload") { - // Will block forever trying to write to a channel that nobody is reading if livereload isn't initalized + // Will block forever trying to write to a channel that nobody is reading if livereload isn't initialized livereload.ForceRefresh() } }