MCPcopy Index your code
hub / github.com/devspace-sh/devspace / New

Function New

pkg/devspace/watch/watch.go:42–65  ·  view source on GitHub ↗

New watches a given glob paths array for changes

(paths []string, exclude []string, pollInterval time.Duration, callback Callback, log log.Logger)

Source from the content-addressed store, hash-verified

40
41// New watches a given glob paths array for changes
42func New(paths []string, exclude []string, pollInterval time.Duration, callback Callback, log log.Logger) (Watcher, error) {
43 ignoreMatcher, err := ignoreparser.CompilePaths(exclude, log)
44 if err != nil {
45 return nil, err
46 }
47
48 watcher := &watcher{
49 Paths: paths,
50 Exclude: ignoreMatcher,
51 PollInterval: pollInterval,
52 Callback: callback,
53 FileMap: make(map[string]os.FileInfo),
54 Log: log,
55 interrupt: make(chan bool),
56 }
57
58 // Initialize filemap
59 _, _, err = watcher.Update()
60 if err != nil {
61 return nil, err
62 }
63
64 return watcher, nil
65}
66
67// Start starts the watching process every second
68func (w *watcher) Start() {

Callers 1

TestWatcherFunction · 0.70

Calls 2

UpdateMethod · 0.95
CompilePathsFunction · 0.92

Tested by 1

TestWatcherFunction · 0.56