File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ bin: clutter
2525.PHONY : clutter
2626clutter :
2727 go build -o $(BINDIR ) /clutter $(GO_BUILD_OPTS ) ./cmd/clutter
28+ go build -o $(BINDIR ) /clutter-nofsnotify --tags nofsnotify $(GO_BUILD_OPTS ) ./cmd/clutter
2829
2930.PHONY : test
3031test : test-unit test-end-to-end
Original file line number Diff line number Diff line change @@ -237,7 +237,6 @@ make install
237237
238238See [ releases] ( https://github.com/cluttercode/clutter/releases ) .
239239
240-
241240## TODO
242241
243242- [ ] More tests.
Original file line number Diff line number Diff line change 66 "path/filepath"
77 "time"
88
9- "github.com/fsnotify/fsnotify"
109 cli "github.com/urfave/cli/v2"
1110
1211 "github.com/cluttercode/clutter/internal/pkg/index"
10099 return nil
101100 }
102101
103- watcher , err := fsnotify . NewWatcher ()
102+ watcher , err := fsnNewWatcher ()
104103 if err != nil {
105104 return fmt .Errorf ("watcher: %w" , err )
106105 }
@@ -153,7 +152,7 @@ var (
153152 return
154153
155154 case event := <- watcher .Events :
156- if event .Op & (fsnotify . Write | fsnotify . Remove | fsnotify . Rename | fsnotify . Create ) != 0 {
155+ if event .Op & (fsnWrite | fsnRemove | fsnRename | fsnCreate ) != 0 {
157156 z .Infow ("file modified" , "event" , event .Name )
158157 done <- errRefresh
159158 return
Original file line number Diff line number Diff line change 1+ // +build !nofsnotify
2+
3+ package main
4+
5+ import (
6+ "github.com/fsnotify/fsnotify"
7+ )
8+
9+ var (
10+ fsnCreate = fsnotify .Create
11+ fsnWrite = fsnotify .Write
12+ fsnRemove = fsnotify .Remove
13+ fsnRename = fsnotify .Rename
14+ )
15+
16+ var fsnNewWatcher = fsnotify .NewWatcher
Original file line number Diff line number Diff line change 1+ // +build nofsnotify
2+
3+ package main
4+
5+ import "errors"
6+
7+ type Op uint32
8+
9+ const (
10+ fsnCreate Op = iota
11+ fsnWrite
12+ fsnRemove
13+ fsnRename
14+ )
15+
16+ type Event struct {
17+ Name string
18+ Op Op
19+ }
20+
21+ type Watcher struct {
22+ Errors chan error
23+ Events chan Event
24+ }
25+
26+ func (w * Watcher ) Add (name string ) error { return nil }
27+ func (w * Watcher ) Close () error { return nil }
28+
29+ func fsnNewWatcher () (* Watcher , error ) {
30+ return nil , errors .New ("fsnotify is not supported" )
31+ }
You can’t perform that action at this time.
0 commit comments