mirror of
https://github.com/tmedwards/tweego.git
synced 2025-07-04 21:50:33 -04:00
[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.
This commit is contained in:
parent
6e2090b23d
commit
2d91f1ce96
1 changed files with 2 additions and 6 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue