diff options
Diffstat (limited to 'commands/hugobuilder.go')
-rw-r--r-- | commands/hugobuilder.go | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/commands/hugobuilder.go b/commands/hugobuilder.go index f5bc73087..657048d48 100644 --- a/commands/hugobuilder.go +++ b/commands/hugobuilder.go @@ -75,9 +75,14 @@ type hugoBuilder struct { errState hugoBuilderErrState } +var errConfigNotSet = errors.New("config not set") + func (c *hugoBuilder) withConfE(fn func(conf *commonConfig) error) error { c.confmu.Lock() defer c.confmu.Unlock() + if c.conf == nil { + return errConfigNotSet + } return fn(c.conf) } @@ -585,7 +590,7 @@ func (c *hugoBuilder) fullRebuild(changeType string) { time.Sleep(2 * time.Second) }() - defer c.r.timeTrack(time.Now(), "Rebuilt") + defer c.postBuild("Rebuilt", time.Now()) err := c.reloadConfig() if err != nil { @@ -855,7 +860,7 @@ func (c *hugoBuilder) handleEvents(watcher *watcher.Batcher, c.changeDetector.PrepareNew() func() { - defer c.r.timeTrack(time.Now(), "Total") + defer c.postBuild("Total", time.Now()) if err := c.rebuildSites(dynamicEvents); err != nil { c.handleBuildErr(err, "Rebuild failed") } @@ -901,6 +906,13 @@ func (c *hugoBuilder) handleEvents(watcher *watcher.Batcher, } } +func (c *hugoBuilder) postBuild(what string, start time.Time) { + if h, err := c.hugo(); err == nil && h.Conf.Running() { + h.LogServerAddresses() + } + c.r.timeTrack(start, what) +} + func (c *hugoBuilder) hugo() (*hugolib.HugoSites, error) { var h *hugolib.HugoSites if err := c.withConfE(func(conf *commonConfig) error { |