shithub: hugo

Download patch

ref: 8b0c3b9b271c7f3eaa812f7a98bb738fe9cc1846
parent: 34c87421b82b967a8ae85261ca9a3e9fe7b156da
author: Cameron Moore <[email protected]>
date: Thu Dec 22 17:44:35 EST 2016

helpers: Remove "no theme set" warning

Fixes #2821

--- a/commands/hugo.go
+++ b/commands/hugo.go
@@ -472,7 +472,9 @@
 	useStatic := true
 
 	if err != nil {
-		jww.WARN.Println(err)
+		if err != helpers.ErrThemeUndefined {
+			jww.WARN.Println(err)
+		}
 		useTheme = false
 	} else {
 		if _, err := source.Stat(themeDir); os.IsNotExist(err) {
--- a/helpers/path.go
+++ b/helpers/path.go
@@ -31,6 +31,13 @@
 	"golang.org/x/text/unicode/norm"
 )
 
+var (
+	// ErrThemeUndefined is returned when a theme has not be defined by the user.
+	ErrThemeUndefined = errors.New("no theme set")
+
+	ErrWalkRootTooShort = errors.New("Path too short. Stop walking.")
+)
+
 // filepathPathBridge is a bridge for common functionality in filepath vs path
 type filepathPathBridge interface {
 	Base(in string) string
@@ -207,7 +214,7 @@
 
 func getThemeDirPath(path string) (string, error) {
 	if !ThemeSet() {
-		return "", errors.New("No theme set")
+		return "", ErrThemeUndefined
 	}
 
 	themeDir := filepath.Join(GetThemeDir(), path)
@@ -484,8 +491,6 @@
 
 	return path, nil
 }
-
-var ErrWalkRootTooShort = errors.New("Path too short. Stop walking.")
 
 // SymbolicWalk is like filepath.Walk, but it supports the root being a
 // symbolic link. It will still not follow symbolic links deeper down in