Fix static file change detection on Windows.

Fixed windows uses different filepath separator. The filepath.ToSlash
shouldn't be used, because it can cause errors in filepath suffix and prefix
testing since "c:\a" isn't a prefix of "c:/a/b/c".
This commit is contained in:
Egon Elbre authored and spf13 committed 2013-12-28 13:45:38 -05:00
1 parent 065928fcf0
commit e46148f948
2 files changed
+10 -6

No files matched your search

+9 -5
View File
@@ -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))
}
}
}
+1 -1
View File
@@ -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) {