shithub: hugo

Download patch

ref: 61258858af90fc43bea406af5f065d0b2e6c94dc
parent: 736677a21d8b10c3a34c5f383849ba186ff296b1
author: spf13 <[email protected]>
date: Mon Jul 29 21:26:02 EDT 2013

copying static content to destination

--- a/main.go
+++ b/main.go
@@ -16,8 +16,10 @@
 import (
 	"fmt"
 	"github.com/howeyc/fsnotify"
+	"github.com/mostafah/fsync"
 	flag "github.com/ogier/pflag"
 	"github.com/spf13/hugo/hugolib"
+	"log"
 	"net/http"
 	"os"
 	"path/filepath"
@@ -63,10 +65,6 @@
 	config.UglyUrls = *uglyUrls
 	config.Verbose = *verbose
 
-	if *destination != "" {
-		config.PublishDir = *destination
-	}
-
 	if *baseUrl != "" {
 		config.BaseUrl = *baseUrl
 	} else if *server {
@@ -73,6 +71,10 @@
 		config.BaseUrl = "http://localhost:" + *port
 	}
 
+	if *destination != "" {
+		config.PublishDir = *destination
+	}
+
 	if *version {
 		fmt.Println("Hugo Static Site Generator v0.8")
 	}
@@ -90,6 +92,12 @@
 		for i := 0; i < *cpuprofile; i++ {
 			_ = buildSite(config)
 		}
+	}
+
+	// Copy Static to Destination first
+	err := fsync.SyncDel(config.GetAbsPath(config.PublishDir+"/"), config.GetAbsPath(config.StaticDir+"/"))
+	if err != nil {
+		log.Fatalf("Error copying static files to %s: %v", config.GetAbsPath(config.PublishDir), err)
 	}
 
 	if *checkMode {