Skip to content

Commit

Permalink
The missing static directory shouldn't fail the build
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kzys authored and bep committed Oct 17, 2015
1 parent 4e9a5d8 commit 3a41254
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions commands/hugo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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.
Expand Down

0 comments on commit 3a41254

Please sign in to comment.