Skip to content

Commit

Permalink
commands: Include theme name in version mismatch error
Browse files Browse the repository at this point in the history
Fixes #5044
  • Loading branch information
bep committed Aug 14, 2018
1 parent c81fbf4 commit e5052f4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions commands/commandeer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"os"
"path/filepath"
"regexp"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -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 {
cfg.Logger.ERROR.Printf("Current theme does not support Hugo version %s. Minimum version required is %s\n",
helpers.CurrentHugoVersion.ReleaseVersion(), minVersion)
name := filepath.Base(dir)
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
Expand Down
4 changes: 2 additions & 2 deletions commands/hugo.go
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ func pickOneWriteOrCreatePath(events []fsnotify.Event) string {

// isThemeVsHugoVersionMismatch returns whether the current Hugo version is
// 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() {
return
}
Expand All @@ -970,7 +970,7 @@ func (c *commandeer) isThemeVsHugoVersionMismatch(fs afero.Fs) (mismatch bool, r

if minVersion, ok := tomlMeta["min_version"]; ok {
if helpers.CompareVersion(minVersion) > 0 {
return true, fmt.Sprint(minVersion)
return absThemeDir, true, fmt.Sprint(minVersion)
}
}

Expand Down

0 comments on commit e5052f4

Please sign in to comment.