commands: Include theme name in version mismatch error

Fixes #5044
This commit is contained in:
Bjørn Erik Pedersen 2018-08-14 21:21:39 +02:00
parent c81fbf4625
commit e5052f4e09
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F
2 changed files with 7 additions and 5 deletions

View file

@ -17,6 +17,7 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"regexp" "regexp"
"strings"
"sync" "sync"
"time" "time"
@ -324,11 +325,12 @@ func (c *commandeer) loadConfig(mustHaveConfigFile, running bool) error {
} }
} }
themeVersionMismatch, minVersion := c.isThemeVsHugoVersionMismatch(sourceFs) dir, themeVersionMismatch, minVersion := c.isThemeVsHugoVersionMismatch(sourceFs)
if themeVersionMismatch { if themeVersionMismatch {
cfg.Logger.ERROR.Printf("Current theme does not support Hugo version %s. Minimum version required is %s\n", name := filepath.Base(dir)
helpers.CurrentHugoVersion.ReleaseVersion(), minVersion) cfg.Logger.ERROR.Printf("%s theme does not support Hugo version %s. Minimum version required is %s\n",
strings.ToUpper(name), helpers.CurrentHugoVersion.ReleaseVersion(), minVersion)
} }
return nil return nil

View file

@ -945,7 +945,7 @@ func pickOneWriteOrCreatePath(events []fsnotify.Event) string {
// isThemeVsHugoVersionMismatch returns whether the current Hugo version is // isThemeVsHugoVersionMismatch returns whether the current Hugo version is
// less than any of the themes' min_version. // less than any of the themes' min_version.
func (c *commandeer) isThemeVsHugoVersionMismatch(fs afero.Fs) (mismatch bool, requiredMinVersion string) { func (c *commandeer) isThemeVsHugoVersionMismatch(fs afero.Fs) (dir string, mismatch bool, requiredMinVersion string) {
if !c.hugo.PathSpec.ThemeSet() { if !c.hugo.PathSpec.ThemeSet() {
return return
} }
@ -970,7 +970,7 @@ func (c *commandeer) isThemeVsHugoVersionMismatch(fs afero.Fs) (mismatch bool, r
if minVersion, ok := tomlMeta["min_version"]; ok { if minVersion, ok := tomlMeta["min_version"]; ok {
if helpers.CompareVersion(minVersion) > 0 { if helpers.CompareVersion(minVersion) > 0 {
return true, fmt.Sprint(minVersion) return absThemeDir, true, fmt.Sprint(minVersion)
} }
} }