diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-06-30 08:47:11 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-06-30 10:24:28 +0200 |
commit | ffd37d4f757c8448afd49823d2252532be7f7e00 (patch) | |
tree | 2b09f9d83a9be6966e74731fed741114a49a197c /commands | |
parent | b4b65245b28e623e927941d4a07635535e6377fc (diff) |
Only print the path warnings once
We could reset and rerun it on server rebuilds, but that report needs a full build to make sense.
Also clean up the config vs flags in this area: Make all config settings match the flags e.g. `printPathWarnings`, but set up aliases for the
old.
Fixes #11187
Diffstat (limited to 'commands')
-rw-r--r-- | commands/commandeer.go | 16 | ||||
-rw-r--r-- | commands/helpers.go | 8 | ||||
-rw-r--r-- | commands/hugobuilder.go | 8 |
3 files changed, 10 insertions, 22 deletions
diff --git a/commands/commandeer.go b/commands/commandeer.go index 26bd25c01..1a4ecf64f 100644 --- a/commands/commandeer.go +++ b/commands/commandeer.go @@ -110,12 +110,10 @@ type rootCommand struct { environment string // Common build flags. - baseURL string - gc bool - poll string - forceSyncStatic bool - printPathWarnings bool - printUnusedTemplates bool + baseURL string + gc bool + poll string + forceSyncStatic bool // Profile flags (for debugging of performance problems) cpuprofile string @@ -288,7 +286,7 @@ func (r *rootCommand) ConfigFromProvider(key int32, cfg config.Provider) (*commo htime.Clock = clock.Start(configs.Base.C.Clock) } - if base.LogPathWarnings { + if base.PrintPathWarnings { // Note that we only care about the "dynamic creates" here, // so skip the static fs. fs.PublishDir = hugofs.NewCreateCountingFs(fs.PublishDir) @@ -544,8 +542,8 @@ func applyLocalFlagsBuild(cmd *cobra.Command, r *rootCommand) { cmd.Flags().BoolP("noChmod", "", false, "don't sync permission mode of files") cmd.Flags().BoolP("noBuildLock", "", false, "don't create .hugo_build.lock file") cmd.Flags().BoolP("printI18nWarnings", "", false, "print missing translations") - cmd.Flags().BoolVarP(&r.printPathWarnings, "printPathWarnings", "", false, "print warnings on duplicate target paths etc.") - cmd.Flags().BoolVarP(&r.printUnusedTemplates, "printUnusedTemplates", "", false, "print warnings on unused templates.") + cmd.Flags().BoolP("printPathWarnings", "", false, "print warnings on duplicate target paths etc.") + cmd.Flags().BoolP("printUnusedTemplates", "", false, "print warnings on unused templates.") cmd.Flags().StringVarP(&r.cpuprofile, "profile-cpu", "", "", "write cpu profile to `file`") cmd.Flags().StringVarP(&r.memprofile, "profile-mem", "", "", "write memory profile to `file`") cmd.Flags().BoolVarP(&r.printm, "printMemoryUsage", "", false, "print memory usage to screen at intervals") diff --git a/commands/helpers.go b/commands/helpers.go index c342ce2c7..5021221fb 100644 --- a/commands/helpers.go +++ b/commands/helpers.go @@ -79,11 +79,9 @@ func flagsToCfgWithAdditionalConfigBase(cd *simplecobra.Commandeer, cfg config.P // Flags with a different name in the config. keyMap := map[string]string{ - "minify": "minifyOutput", - "destination": "publishDir", - "printI18nWarnings": "logI18nWarnings", - "printPathWarnings": "logPathWarnings", - "editor": "newContentEditor", + "minify": "minifyOutput", + "destination": "publishDir", + "editor": "newContentEditor", } // Flags that we for some reason don't want to expose in the site config. diff --git a/commands/hugobuilder.go b/commands/hugobuilder.go index 3e96bfc73..b5cd0c2bb 100644 --- a/commands/hugobuilder.go +++ b/commands/hugobuilder.go @@ -43,7 +43,6 @@ import ( "github.com/gohugoio/hugo/hugolib/filesystems" "github.com/gohugoio/hugo/livereload" "github.com/gohugoio/hugo/resources/page" - "github.com/gohugoio/hugo/tpl" "github.com/gohugoio/hugo/watcher" "github.com/spf13/fsync" "golang.org/x/sync/errgroup" @@ -418,13 +417,6 @@ func (c *hugoBuilder) build() error { return err } - if c.r.printUnusedTemplates { - unusedTemplates := h.Tmpl().(tpl.UnusedTemplatesProvider).UnusedTemplates() - for _, unusedTemplate := range unusedTemplates { - c.r.logger.Warnf("Template %s is unused, source file %s", unusedTemplate.Name(), unusedTemplate.Filename()) - } - } - h.PrintProcessingStats(os.Stdout) c.r.Println() } |