From 231374a1fa0faf66ca3aa51368b97ea6e7317803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Wed, 24 May 2023 15:53:49 +0200 Subject: Fix regression when loading config -e is empty or HUGO_ENV or HUGO_ENVIRONMENT is set Fixes #11013 --- testscripts/commands/hugo.txt | 4 ++-- testscripts/commands/hugo_configdev_env.txt | 19 +++++++++++++++++++ .../commands/hugo_configdev_environment.txt | 22 ++++++++++++++++++++++ testscripts/commands/hugo_configprod.txt | 18 ++++++++++++++++++ 4 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 testscripts/commands/hugo_configdev_env.txt create mode 100644 testscripts/commands/hugo_configdev_environment.txt create mode 100644 testscripts/commands/hugo_configprod.txt (limited to 'testscripts/commands') diff --git a/testscripts/commands/hugo.txt b/testscripts/commands/hugo.txt index 9907f5258..60f7ffe71 100644 --- a/testscripts/commands/hugo.txt +++ b/testscripts/commands/hugo.txt @@ -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 -- diff --git a/testscripts/commands/hugo_configdev_env.txt b/testscripts/commands/hugo_configdev_env.txt new file mode 100644 index 000000000..758f4fc96 --- /dev/null +++ b/testscripts/commands/hugo_configdev_env.txt @@ -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" +--- diff --git a/testscripts/commands/hugo_configdev_environment.txt b/testscripts/commands/hugo_configdev_environment.txt new file mode 100644 index 000000000..037148178 --- /dev/null +++ b/testscripts/commands/hugo_configdev_environment.txt @@ -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" +--- diff --git a/testscripts/commands/hugo_configprod.txt b/testscripts/commands/hugo_configprod.txt new file mode 100644 index 000000000..ac046b205 --- /dev/null +++ b/testscripts/commands/hugo_configprod.txt @@ -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" +--- -- cgit v1.2.3