shithub: hugo

Download patch

ref: 3a412543f617cf9fa460061aa5a33db43675c9f9
parent: 4e9a5d8bd173c3db7572210db982e56c2bc0e007
author: Kato Kazuyoshi <[email protected]>
date: Wed Oct 14 20:36:27 EDT 2015

The missing static directory shouldn't fail the build

The lack of the directory would be worth to warn, since the directory is
created by "huge new site". But it doesn't have to fail the build.

This change fixes #759.

--- a/commands/hugo.go
+++ b/commands/hugo.go
@@ -328,12 +328,6 @@
 }
 
 func copyStatic() error {
-	staticDir := helpers.AbsPathify(viper.GetString("StaticDir")) + "/"
-	if _, err := os.Stat(staticDir); os.IsNotExist(err) {
-		jww.ERROR.Println("Unable to find Static Directory:", staticDir)
-		return nil
-	}
-
 	publishDir := helpers.AbsPathify(viper.GetString("PublishDir")) + "/"
 
 	syncer := fsync.NewSyncer()
@@ -347,15 +341,21 @@
 		return nil
 	}
 
+	// Copy the theme's static directory
 	if themeDir != "" {
-		// Copy Static to Destination
 		jww.INFO.Println("syncing from", themeDir, "to", publishDir)
 		utils.CheckErr(syncer.Sync(publishDir, themeDir), fmt.Sprintf("Error copying static files of theme to %s", publishDir))
 	}
 
-	// Copy Static to Destination
-	jww.INFO.Println("syncing from", staticDir, "to", publishDir)
-	return syncer.Sync(publishDir, staticDir)
+	// Copy the site's own static directory
+	staticDir := helpers.AbsPathify(viper.GetString("StaticDir")) + "/"
+	if _, err := os.Stat(staticDir); err == nil {
+		jww.INFO.Println("syncing from", staticDir, "to", publishDir)
+		return syncer.Sync(publishDir, staticDir)
+	} else if os.IsNotExist(err) {
+		jww.WARN.Println("Unable to find Static Directory:", staticDir)
+	}
+	return nil
 }
 
 // getDirList provides NewWatcher() with a list of directories to watch for changes.