diff --git a/commands/hugo.go b/commands/hugo.go index a99feb7c0..8cfbc734f 100644 --- a/commands/hugo.go +++ b/commands/hugo.go @@ -198,16 +198,20 @@ func NewWatcher(port int) error { } func watchChange(ev *fsnotify.FileEvent) { + ext := filepath.Ext(ev.Name) + // ignore temp files + istemp := strings.HasSuffix(ext, "~") || (ext == ".swp") || (ext == ".tmp") + if istemp { + return + } + if strings.HasPrefix(ev.Name, Config.GetAbsPath(Config.StaticDir)) { fmt.Println("Static file changed, syncing\n") utils.CheckErr(copyStatic(), fmt.Sprintf("Error copying static files to %s", Config.GetAbsPath(Config.PublishDir))) } else { 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(true)) - } + fmt.Println("Change detected, rebuilding site\n") + utils.StopOnErr(buildSite(true)) } } } diff --git a/hugolib/config.go b/hugolib/config.go index 9a737d7b7..e2d304937 100644 --- a/hugolib/config.go +++ b/hugolib/config.go @@ -161,7 +161,7 @@ func (c *Config) GetAbsPath(name string) string { return name } - return filepath.ToSlash(filepath.Join(c.GetPath(), name)) + return filepath.Join(c.GetPath(), name) } func (c *Config) findConfigFile(configFileName string) (string, error) {