You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
that may get passed as a second argument with `add`, `addDir`, and `change` events
528
+
when available, set this to `true` to ensure it is provided with every event. May
529
+
have a slight performance penalty.
530
+
531
+
Read about the full set of options in [`chokidar`'s README][chokidar]
513
532
514
533
#### fn
515
534
Type: `Function`
@@ -518,15 +537,13 @@ An [async](#async-support) function to run when a file changes.
518
537
519
538
`gulp.watch` returns a wrapped [chokidar] FSWatcher object. If provided,
520
539
the callback will be triggered upon any `add`, `change`, or `unlink` event.
521
-
Listeners can also be set directly for any of [chokidar]'s events.
540
+
Listeners can also be set directly for any of [chokidar]'s events, such as
541
+
`addDir`, `unlinkDir`, and `error`.
522
542
523
543
```js
524
544
var watcher =gulp.watch('js/**/*.js', gulp.parallel('uglify', 'reload'));
525
545
watcher.on('change', function(path, stats) {
526
546
console.log('File '+ path +' was changed');
527
-
if (stats) {
528
-
console.log('changed size to '+stats.size);
529
-
}
530
547
});
531
548
532
549
watcher.on('unlink', function(path) {
@@ -544,7 +561,22 @@ Type: Object
544
561
545
562
[File stats](http://nodejs.org/api/fs.html#fs_class_fs_stats) object when available.
546
563
Setting the `alwaysStat` option to true will ensure that a file stat object will be
547
-
available.
564
+
provided.
565
+
566
+
#### watcher methods
567
+
568
+
##### watcher.close()
569
+
570
+
Shuts down the file watcher.
571
+
572
+
##### watcher.add(glob)
573
+
574
+
Watch additional glob (or array of globs) with an already-running watcher instance.
575
+
576
+
##### watcher.unwatch(glob)
577
+
578
+
Stop watching a glob (or array of globs) while leaving the watcher running and
579
+
emitting events for the remaining paths it is watching.
0 commit comments