diff options
Diffstat (limited to 'commands/commandeer.go')
-rw-r--r-- | commands/commandeer.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/commands/commandeer.go b/commands/commandeer.go index 5b192c172..20090cccd 100644 --- a/commands/commandeer.go +++ b/commands/commandeer.go @@ -15,6 +15,7 @@ package commands import ( "errors" + "fmt" "io/ioutil" "net" "os" @@ -28,9 +29,11 @@ import ( "golang.org/x/sync/semaphore" "github.com/gohugoio/hugo/common/herrors" + "github.com/gohugoio/hugo/common/htime" "github.com/gohugoio/hugo/common/hugo" "github.com/gohugoio/hugo/common/paths" + "github.com/spf13/cast" jww "github.com/spf13/jwalterweatherman" "github.com/gohugoio/hugo/common/loggers" @@ -41,6 +44,7 @@ import ( "github.com/gohugoio/hugo/hugolib" "github.com/spf13/afero" + "github.com/bep/clock" "github.com/bep/debounce" "github.com/bep/overlayfs" "github.com/gohugoio/hugo/common/types" @@ -164,6 +168,20 @@ func (c *commandeer) initFs(fs *hugofs.Fs) error { return nil } +func (c *commandeer) initClock() error { + bt := c.Cfg.GetString("clock") + if bt == "" { + return nil + } + + t, err := cast.StringToDateInDefaultLocation(bt, nil) + if err != nil { + return fmt.Errorf(`failed to parse "clock" flag: %s`, err) + } + htime.Clock = clock.Start(t) + return nil +} + func newCommandeer(mustHaveConfigFile, failOnInitErr, running bool, h *hugoBuilderCommon, f flagsToConfigHandler, cfgInit func(c *commandeer) error, subCmdVs ...*cobra.Command) (*commandeer, error) { var rebuildDebouncer func(f func()) if running { @@ -341,6 +359,11 @@ func (c *commandeer) loadConfig() error { c.configFiles = configFiles + err = c.initClock() + if err != nil { + return err + } + if l, ok := c.Cfg.Get("languagesSorted").(langs.Languages); ok { c.languagesConfigured = true c.languages = l |