@@ -504,7 +504,7 @@ Type: `Array`, `String` or `Function`
504
504
A task name, a function or an array of either.
505
505
506
506
507
- ### gulp.watch(glob[ , opts] , fn)
507
+ ### gulp.watch(glob[ , opts] [ , fn ] )
508
508
509
509
Watch files and do something when a file changes.
510
510
File watching is provided by the [ ` chokidar ` ] [ chokidar ] module.
@@ -515,7 +515,7 @@ Please report any file watching problems directly to its
515
515
gulp .watch (' js/**/*.js' , gulp .parallel (' uglify' , ' reload' ));
516
516
```
517
517
518
- In the example, ` gulp.watch ` runs the function returned by gulp.parallel each
518
+ In the example, ` gulp.watch ` runs the function returned by ` gulp.parallel ` each
519
519
time a file with the ` js ` extension in ` js/ ` is updated.
520
520
521
521
#### glob
@@ -548,12 +548,14 @@ Read about the full set of options in [`chokidar`'s README][chokidar].
548
548
#### fn
549
549
Type: ` Function `
550
550
551
- An [ async] ( #async-support ) function to run when a file changes.
551
+ An [ async] ( #async-support ) function to run when a file changes. Does not provide
552
+ access to the ` path ` parameter.
552
553
553
554
` gulp.watch ` returns a wrapped [ chokidar] FSWatcher object. If provided,
554
555
the callback will be triggered upon any ` add ` , ` change ` , or ` unlink ` event.
555
556
Listeners can also be set directly for any of [ chokidar] 's events, such as
556
- ` addDir ` , ` unlinkDir ` , and ` error ` .
557
+ ` addDir ` , ` unlinkDir ` , and ` error ` . You must set listeners directly to get
558
+ access to chokidar's callback parameters, such as ` path ` .
557
559
558
560
``` js
559
561
var watcher = gulp .watch (' js/**/*.js' , gulp .parallel (' uglify' , ' reload' ));
@@ -569,7 +571,7 @@ watcher.on('unlink', function(path) {
569
571
##### path
570
572
Type: ` String `
571
573
572
- The relative path of the document .
574
+ Path to the file. If ` opts.cwd ` is set, ` path ` is relative to it .
573
575
574
576
##### stats
575
577
Type: ` Object `
0 commit comments