shithub: hugo

Download patch

ref: cd71eb738947696cae71cb39027996d108221add
parent: a5606b06ca6144542b4201a73c5b6c262f946ed3
author: spf13 <[email protected]>
date: Thu Oct 24 12:45:24 EDT 2013

Watching doesn't built site 2x on write (ignores rename events). Also ignores temporary files written by editors.

--- a/commands/hugo.go
+++ b/commands/hugo.go
@@ -181,7 +181,12 @@
 		fmt.Println("Static file changed, syncing\n")
 		utils.CheckErr(copyStatic(), fmt.Sprintf("Error copying static files to %s", Config.GetAbsPath(Config.PublishDir)))
 	} else {
-		fmt.Println("Change detected, rebuilding site\n")
-		utils.StopOnErr(buildSite())
+		if !ev.IsRename() { // Rename is always accompanied by a create or modify
+			// Ignoring temp files created by editors (vim)
+			if !strings.HasSuffix(ev.Name, "~") && !strings.HasSuffix(ev.Name, ".swp") {
+				fmt.Println("Change detected, rebuilding site\n")
+				utils.StopOnErr(buildSite())
+			}
+		}
 	}
 }