commands: Fix --panicOnWarning flag having no effect with module version warnings

The --panicOnWarning flag was not wired into the root command's logger,
so warnings emitted during config loading (such as module version
incompatibility warnings) would not trigger a panic.

Bind the panicOnWarning flag to the rootCommand struct and set the
PanicOnWarningHook on the logger created in createLogger.

Fixes #14524

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Bjørn Erik Pedersen
2026-02-16 00:09:17 +01:00
parent ab62320d6b
commit 3f9d0ad2b6
4 changed files with 31 additions and 1 deletions
@@ -0,0 +1,13 @@
! hugo --panicOnWarning
stderr 'is not compatible with this Hugo'
-- hugo.toml --
baseURL="https://example.org"
[module]
[module.hugoVersion]
min = "0.148.0"
max = "0.148.0"
-- layouts/all.html --
All.