helpers: Remove "no theme set" warning
authorCameron Moore <moorereason@gmail.com>
Fri, 23 Dec 2016 04:44:35 +0000 (22:44 -0600)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Fri, 23 Dec 2016 18:48:50 +0000 (19:48 +0100)
Fixes #2821

commands/hugo.go
helpers/path.go

index 153980cb10e140af31fe9a7ee5712dfc91f7d16c..32846f871d474a9e43792f5e65dee187f853fd23 100644 (file)
@@ -472,7 +472,9 @@ func getStaticSourceFs() afero.Fs {
        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) {
index 7dea0b0dd0c7d95b038270709347ea7c6f32f9cc..6e2422d05c47e865cc60dfd928ab950fb9ca2b2c 100644 (file)
@@ -31,6 +31,13 @@ import (
        "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 GetThemeI18nDirPath() (string, error) {
 
 func getThemeDirPath(path string) (string, error) {
        if !ThemeSet() {
-               return "", errors.New("No theme set")
+               return "", ErrThemeUndefined
        }
 
        themeDir := filepath.Join(GetThemeDir(), path)
@@ -485,8 +492,6 @@ func FindCWD() (string, error) {
        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
 // the file structure