mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-27 06:00:25 +03:00
Misc config loading fixes
The main motivation behind this is simplicity and correctnes, but the new small config library is also faster: ``` BenchmarkDefaultConfigProvider/Viper-16 252418 4546 ns/op 2720 B/op 30 allocs/op BenchmarkDefaultConfigProvider/Custom-16 450756 2651 ns/op 1008 B/op 6 allocs/op ``` Fixes #8633 Fixes #8618 Fixes #8630 Updates #8591 Closes #6680 Closes #5192
This commit is contained in:
parent
a886dd53b8
commit
d392893cd7
107 changed files with 2159 additions and 1060 deletions
|
@ -20,6 +20,8 @@ import (
|
|||
"math/rand"
|
||||
"os"
|
||||
|
||||
"github.com/gohugoio/hugo/config"
|
||||
|
||||
"github.com/gohugoio/hugo/resources/resource_transformers/tocss/dartsass"
|
||||
|
||||
"path/filepath"
|
||||
|
@ -35,8 +37,6 @@ import (
|
|||
|
||||
"github.com/gohugoio/hugo/htesting"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
|
||||
qt "github.com/frankban/quicktest"
|
||||
|
||||
"github.com/gohugoio/hugo/hugofs"
|
||||
|
@ -65,7 +65,7 @@ func TestSCSSWithIncludePaths(t *testing.T) {
|
|||
c.Assert(err, qt.IsNil)
|
||||
defer clean()
|
||||
|
||||
v := viper.New()
|
||||
v := config.New()
|
||||
v.Set("workingDir", workDir)
|
||||
b := newTestSitesBuilder(c).WithLogger(loggers.NewErrorLogger())
|
||||
// Need to use OS fs for this.
|
||||
|
@ -130,7 +130,7 @@ func TestSCSSWithRegularCSSImport(t *testing.T) {
|
|||
c.Assert(err, qt.IsNil)
|
||||
defer clean()
|
||||
|
||||
v := viper.New()
|
||||
v := config.New()
|
||||
v.Set("workingDir", workDir)
|
||||
b := newTestSitesBuilder(c).WithLogger(loggers.NewErrorLogger())
|
||||
// Need to use OS fs for this.
|
||||
|
@ -230,7 +230,7 @@ func TestSCSSWithThemeOverrides(t *testing.T) {
|
|||
theme := "mytheme"
|
||||
themesDir := filepath.Join(workDir, "themes")
|
||||
themeDirs := filepath.Join(themesDir, theme)
|
||||
v := viper.New()
|
||||
v := config.New()
|
||||
v.Set("workingDir", workDir)
|
||||
v.Set("theme", theme)
|
||||
b := newTestSitesBuilder(c).WithLogger(loggers.NewErrorLogger())
|
||||
|
@ -345,7 +345,7 @@ func TestSCSSWithIncludePathsSass(t *testing.T) {
|
|||
c.Assert(err, qt.IsNil)
|
||||
defer clean1()
|
||||
|
||||
v := viper.New()
|
||||
v := config.New()
|
||||
v.Set("workingDir", workDir)
|
||||
v.Set("theme", "mytheme")
|
||||
b := newTestSitesBuilder(t).WithLogger(loggers.NewErrorLogger())
|
||||
|
@ -974,7 +974,7 @@ h1 {
|
|||
|
||||
var logBuf bytes.Buffer
|
||||
|
||||
newTestBuilder := func(v *viper.Viper) *sitesBuilder {
|
||||
newTestBuilder := func(v config.Provider) *sitesBuilder {
|
||||
v.Set("workingDir", workDir)
|
||||
v.Set("disableKinds", []string{"taxonomy", "term", "page"})
|
||||
logger := loggers.NewBasicLoggerForWriter(jww.LevelInfo, &logBuf)
|
||||
|
@ -997,7 +997,7 @@ Styles Content: Len: {{ len $styles.Content }}|
|
|||
return b
|
||||
}
|
||||
|
||||
b := newTestBuilder(viper.New())
|
||||
b := newTestBuilder(config.New())
|
||||
|
||||
cssDir := filepath.Join(workDir, "assets", "css", "components")
|
||||
b.Assert(os.MkdirAll(cssDir, 0777), qt.IsNil)
|
||||
|
@ -1049,7 +1049,7 @@ Styles Content: Len: 770878|
|
|||
build := func(s string, shouldFail bool) error {
|
||||
b.Assert(os.RemoveAll(filepath.Join(workDir, "public")), qt.IsNil)
|
||||
|
||||
v := viper.New()
|
||||
v := config.New()
|
||||
v.Set("build", map[string]interface{}{
|
||||
"useResourceCacheWhen": s,
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue