From 6dd60fca73ff96b48064bb8c6586631a2370ffc6 Mon Sep 17 00:00:00 2001 From: Bjørn Erik Pedersen Date: Wed, 7 Oct 2020 10:46:19 +0200 Subject: Revert "deps: Update to github.com/tdewolff/minify v2.9.4" Closes #7792 This reverts commit b254532b52785954c98a473a635b9cea016d8565. --- minifiers/config.go | 27 ++++++--------------------- minifiers/minifiers_test.go | 25 +------------------------ 2 files changed, 7 insertions(+), 45 deletions(-) (limited to 'minifiers') diff --git a/minifiers/config.go b/minifiers/config.go index 0715344a7..5ee3aa2f9 100644 --- a/minifiers/config.go +++ b/minifiers/config.go @@ -18,7 +18,6 @@ import ( "github.com/gohugoio/hugo/config" "github.com/gohugoio/hugo/docshelper" "github.com/gohugoio/hugo/parser" - "github.com/spf13/cast" "github.com/mitchellh/mapstructure" "github.com/tdewolff/minify/v2/css" @@ -36,16 +35,18 @@ var defaultTdewolffConfig = tdewolffConfig{ KeepEndTags: true, KeepDefaultAttrVals: true, KeepWhitespace: false, - KeepQuotes: false, + // KeepQuotes: false, >= v2.6.2 }, CSS: css.Minifier{ - Precision: 0, - KeepCSS2: true, + Decimals: -1, // will be deprecated + // Precision: 0, // use Precision with >= v2.7.0 + KeepCSS2: true, }, JS: js.Minifier{}, JSON: json.Minifier{}, SVG: svg.Minifier{ - Precision: 0, + Decimals: -1, // will be deprecated + // Precision: 0, // use Precision with >= v2.7.0 }, XML: xml.Minifier{ KeepWhitespace: false, @@ -98,22 +99,6 @@ func decodeConfig(cfg config.Provider) (conf minifyConfig, err error) { m := maps.ToStringMap(v) - // Handle upstream renames. - if td, found := m["tdewolff"]; found { - tdm := cast.ToStringMap(td) - for _, key := range []string{"css", "svg"} { - if v, found := tdm[key]; found { - vm := cast.ToStringMap(v) - if vv, found := vm["decimal"]; found { - vvi := cast.ToInt(vv) - if vvi > 0 { - vm["precision"] = vvi - } - } - } - } - } - err = mapstructure.WeakDecode(m, &conf) if err != nil { diff --git a/minifiers/minifiers_test.go b/minifiers/minifiers_test.go index cbd2f40ac..fb222fd6d 100644 --- a/minifiers/minifiers_test.go +++ b/minifiers/minifiers_test.go @@ -34,7 +34,7 @@ func TestNew(t *testing.T) { var rawJS string var minJS string rawJS = " var foo =1 ; foo ++ ; " - minJS = "var foo=1;foo++" + minJS = "var foo=1;foo++;" var rawJSON string var minJSON string @@ -168,26 +168,3 @@ func TestBugs(t *testing.T) { } } - -// Renamed to Precision in v2.7.0. Check that we support both. -func TestDecodeConfigDecimalIsNowPrecision(t *testing.T) { - c := qt.New(t) - v := viper.New() - v.Set("minify", map[string]interface{}{ - "disablexml": true, - "tdewolff": map[string]interface{}{ - "css": map[string]interface{}{ - "decimal": 3, - }, - "svg": map[string]interface{}{ - "decimal": 3, - }, - }, - }) - - conf, err := decodeConfig(v) - - c.Assert(err, qt.IsNil) - c.Assert(conf.Tdewolff.CSS.Precision, qt.Equals, 3) - -} -- cgit v1.2.3