Fix regression when loading config -e is empty or HUGO_ENV or HUGO_ENVIRONMENT is set

Fixes #11013
This commit is contained in:
Bjørn Erik Pedersen
2023-05-24 15:53:49 +02:00
parent 5adc837904
commit 231374a1fa
6 changed files with 77 additions and 7 deletions

View File

@@ -5,13 +5,13 @@ stdout 'Pages.*|1'
stdout 'Total in'
checkfile public/index.html
checkfile public/p1/index.html
grep 'IsServer: false' public/index.html
grep 'IsServer: false;IsProduction: true' public/index.html
-- hugo.toml --
baseURL = "http://example.org/"
disableKinds = ["RSS", "sitemap", "robotsTXT", "404", "taxonomy", "term"]
-- layouts/index.html --
Home|IsServer: {{ .Site.IsServer }}|
Home|IsServer: {{ .Site.IsServer }};IsProduction: {{ hugo.IsProduction }}|
-- layouts/_default/single.html --
Title: {{ .Title }}
-- content/p1.md --

View File

@@ -0,0 +1,19 @@
# Test the hugo command.
env HUGO_ENV=development
hugo
grep 'myparam: dev§' public/index.html
-- hugo.toml --
baseURL = "http://example.org/"
disableKinds = ["RSS", "sitemap", "robotsTXT", "404", "taxonomy", "term"]
-- layouts/index.html --
myparam: {{ site.Params.myparam }}§
-- layouts/_default/single.html --
Title: {{ .Title }}
-- config/development/params.toml --
myparam = "dev"
-- content/p1.md --
---
title: "P1"
---

View File

@@ -0,0 +1,22 @@
# Test the hugo command.
env HUGO_ENVIRONMENT=development
hugo
grep 'myparam: dev§' public/index.html
hugo -e production
grep 'myparam: §' public/index.html
-- hugo.toml --
baseURL = "http://example.org/"
disableKinds = ["RSS", "sitemap", "robotsTXT", "404", "taxonomy", "term"]
-- layouts/index.html --
myparam: {{ site.Params.myparam }}§
-- layouts/_default/single.html --
Title: {{ .Title }}
-- config/development/params.toml --
myparam = "dev"
-- content/p1.md --
---
title: "P1"
---

View File

@@ -0,0 +1,18 @@
# Test the hugo command.
hugo
grep 'myparam: §' public/index.html
-- hugo.toml --
baseURL = "http://example.org/"
disableKinds = ["RSS", "sitemap", "robotsTXT", "404", "taxonomy", "term"]
-- layouts/index.html --
myparam: {{ site.Params.myparam }}§
-- layouts/_default/single.html --
Title: {{ .Title }}
-- config/development/params.toml --
myparam = "dev"
-- content/p1.md --
---
title: "P1"
---