hugolib: Only set 'allThemes' if there are themes in the config file - hugo - [fork] hugo port for 9front
 (HTM) git clone git@git.drkhsh.at/hugo.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 38204c4ab6fa2aa2ab8bd06ddb3e07b66e5f9646
 (DIR) parent 2f2bc7ff70b90fb11580cc092ef3883bf68d8ad7
 (HTM) Author: Garry McNulty <garrmcnu@gmail.com>
       Date:   Sun, 15 Jul 2018 14:35:41 +0100
       
       hugolib: Only set 'allThemes' if there are themes in the config file
       
       When the 'allThemes' configuration setting is read, it will panic if
       there are no themes. This was a regression introduced in Hugo 0.42.
       
       Also updated a unit test to check for this.
       
       Fixes #4851
       
       Diffstat:
         M hugolib/config.go                   |       5 +++++
         M hugolib/config_test.go              |       2 ++
       
       2 files changed, 7 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/hugolib/config.go b/hugolib/config.go
       @@ -285,6 +285,11 @@ func loadThemeConfig(d ConfigSourceDescriptor, v1 *viper.Viper) ([]string, error
                if err != nil {
                        return nil, err
                }
       +
       +        if len(themeConfigs) == 0 {
       +                return nil, nil
       +        }
       +
                v1.Set("allThemes", themeConfigs)
        
                var configFilenames []string
 (DIR) diff --git a/hugolib/config_test.go b/hugolib/config_test.go
       @@ -42,6 +42,8 @@ func TestLoadConfig(t *testing.T) {
                assert.Equal("side", cfg.GetString("paginatePath"))
                // default
                assert.Equal("layouts", cfg.GetString("layoutDir"))
       +        // no themes
       +        assert.False(cfg.IsSet("allThemes"))
        }
        
        func TestLoadMultiConfig(t *testing.T) {