From 2d91f1ce966dc016e7f1db32a2c3ec1da7a98eb2 Mon Sep 17 00:00:00 2001 From: "Thomas M. Edwards" Date: Mon, 24 Feb 2020 16:19:07 -0600 Subject: [PATCH] [Fix] Fixed usage of old `watcher` `Event` API. Resolves #7. * The `watcher` `Event` API changed from stuffing old/new path into a single field to having them as separate fields. Update the code to use the new API. --- filesystem.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/filesystem.go b/filesystem.go index 4717ee8..1535e26 100644 --- a/filesystem.go +++ b/filesystem.go @@ -12,7 +12,6 @@ import ( "log" "os" "path/filepath" - "strings" "time" // external packages "github.com/radovskyb/watcher" @@ -133,12 +132,9 @@ func watchFilesystem(pathnames []string, outFilename string, buildCallback func( var pathname string switch event.Op { case watcher.Move, watcher.Rename: - // NOTE: Format of Move/Rename event `Path` field: "oldName -> newName". - // TODO: Should probably error out if we can't split the event.Path value. - names := strings.Split(event.Path, " -> ") - pathname = fmt.Sprintf("%s -> %s", relPath(names[0]), relPath(names[1])) + pathname = fmt.Sprintf("%s -> %s", relPath(event.OldPath), relPath(event.Path)) if !build && !isDir { - build = knownFileType(names[0]) || knownFileType(names[1]) + build = knownFileType(event.OldPath) || knownFileType(event.Path) } default: pathname = relPath(event.Path)