-
Notifications
You must be signed in to change notification settings - Fork 16
/
chokidar.node.txt
91 lines (73 loc) · 6.13 KB
/
chokidar.node.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
CHOKIDAR
ALTERNATIVES ==> # - chokidar (prefered)
# - gaze: unmaintained
#Wrapper around FS.watch[File]() that improves it
#Also fixes file watching on macOS
VERSION ==> #3.6.0
/=+===============================+=\
/ : : \
)==: CORE :==(
\ :_______________________________: /
\=+===============================+=/
GLOBS #'GLOB'[_ARR]
#Uses anymatch with default options (see its doc)
#New files in watched directories are watched:
# - 'DIR/**/*', 'DIR', 'DIR/' all work
# - if top-level watched directory removed and re-created, not watched anymore
# - but not for nested watched directories
CHOKIDAR.watch(GLOBS[, OPTS]) #OPTS:
->WATCHER # - persistent BOOL: if true (def), calls ref(), yielding the macrotask
# - ignored GLOB|REGEXP
# - ignoreInitial BOOL (def: false): ignore initial add event
# - followSymlinks BOOL (def: true)
# - cwd 'DIR' (def: null)
# - usePolling BOOL (def: false):
# - if true, uses watchFile(), i.e. slower, but works over networks.
# - also use OPTS.interval NUM (def: 100)
# and OPTS.binaryInterval (def: 300) (for binary files only)
# - can also use ENVVAR CHOKIDAR_USEPOLLING BOOL and CHOKIDAR_INTERVAL NUM
# - depth NUM (def: null): recursion level
# - ignorePermissionErrors BOOL (def: false)
# - atomic BOOL|NUM (def: false):
# - if a file is re-added within NUM (def: 100) ms of being deleted, emit 'change' event instead
# - meant to fix problems with editors that rewrites several times
# - alwaysStat BOOL (def: false): prevents FSSTAT from being sometimes absent from callbacks
# - awaitWriteFinish BOOL (def: false):
# - wait for new files to be entirely written before emitting 'add|change' events
# - will make watching slower
# - can also be OBJ:
# - stabilityThreshold NUM (def: 2000): if after that amount of time, file size hasn't
# changed, consider files to be entirely written
# - pollInterval NUM (def: 100)
# - disableGlobbing BOOL (def: false)
WATCHER.add(GLOBS) #
WATCHER.unwatch(GLOBS)->PROMISE #
WATCHER.close()->PROMISE #Only if OPTS.persistent true
WATCHER.getWatched()
->{ DIR: 'PATH'_ARR, ... } #
WATCHER.on
('add[Dir]|change|unlink[Dir]',
FUNC(PATH, FSSTAT)) #
WATCHER.on('all',
FUNC('EVENT', 'PATH', FSSTAT)) #
WATCHER.on('ready', FUNC()) #
WATCHER.on('error', FUNC(ERROR)) #Mostly errors from FS.* calls
/=+===============================+=\
/ : : \
)==: TOOLS :==(
\ :_______________________________: /
\=+===============================+=/
GLOB-WATCHER(GLOBS[,OPTS][,FUNC])##Like CHOKIDAR.watch(...) except:
->WATCHER ## - fires FUNC() on 'add|change|unlink' events:
## - using async-done (see its doc), i.e. must be async by using PROMISE|STREAM|callback|etc.
## - if FUNC fails, will emit WATCHER 'error' event
## - debounced with OPTS.delay NUM (def: 200) ms
## - default OPTS.ignoreInitial true
##OPTS:
## - events 'EVENT'[_ARR]
## - queue BOOL: if true (def), run FUNC serially if several fired at once
##Version 6.0.0
GULP-WATCH ##Similar but returning as an IOSTREAM instead of as an WATCHER (i.e. EVENTMITTER)
##Prefer GLOB-WATCHER