From e31b1d194655ac3a38fe903ff3995806b129b88a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Mon, 5 Jul 2021 10:13:41 +0200 Subject: commands: Make the --poll flag a duration So you can do: ``` hugo server --poll 700ms ``` See #8720 --- hugolib/site.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'hugolib/site.go') diff --git a/hugolib/site.go b/hugolib/site.go index 2e23368d7..2e7e1d7f9 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -29,6 +29,8 @@ import ( "strings" "time" + "github.com/gohugoio/hugo/common/types" + "github.com/gohugoio/hugo/common/paths" "github.com/gohugoio/hugo/common/constants" @@ -523,13 +525,9 @@ But this also means that your site configuration may not do what you expect. If timeout := 30 * time.Second if cfg.Language.IsSet("timeout") { v := cfg.Language.Get("timeout") - if n := cast.ToInt(v); n > 0 { - timeout = time.Duration(n) * time.Millisecond - } else { - d, err := time.ParseDuration(cast.ToString(v)) - if err == nil { - timeout = d - } + d, err := types.ToDurationE(v) + if err == nil { + timeout = d } } -- cgit v1.2.3