From 3a412543f617cf9fa460061aa5a33db43675c9f9 Mon Sep 17 00:00:00 2001 From: Kato Kazuyoshi Date: Thu, 15 Oct 2015 00:36:27 -0700 Subject: [PATCH] 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. --- commands/hugo.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/commands/hugo.go b/commands/hugo.go index c1c132ab9..d42327d29 100644 --- a/commands/hugo.go +++ b/commands/hugo.go @@ -328,12 +328,6 @@ func build(watches ...bool) { } 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 @@ func copyStatic() error { 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.