@@ -504,7 +504,7 @@ Type: `Array`, `String` or `Function`
504504A task name, a function or an array of either.
505505
506506
507- ### gulp.watch(glob[ , opts] , fn)
507+ ### gulp.watch(glob[ , opts] [ , fn ] )
508508
509509Watch files and do something when a file changes.
510510File watching is provided by the [ ` chokidar ` ] [ chokidar ] module.
@@ -515,7 +515,7 @@ Please report any file watching problems directly to its
515515gulp .watch (' js/**/*.js' , gulp .parallel (' uglify' , ' reload' ));
516516```
517517
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
519519time a file with the ` js ` extension in ` js/ ` is updated.
520520
521521#### glob
@@ -548,12 +548,14 @@ Read about the full set of options in [`chokidar`'s README][chokidar].
548548#### fn
549549Type: ` Function `
550550
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.
552553
553554` gulp.watch ` returns a wrapped [ chokidar] FSWatcher object. If provided,
554555the callback will be triggered upon any ` add ` , ` change ` , or ` unlink ` event.
555556Listeners 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 ` .
557559
558560``` js
559561var watcher = gulp .watch (' js/**/*.js' , gulp .parallel (' uglify' , ' reload' ));
@@ -569,7 +571,7 @@ watcher.on('unlink', function(path) {
569571##### path
570572Type: ` String `
571573
572- The relative path of the document .
574+ Path to the file. If ` opts.cwd ` is set, ` path ` is relative to it .
573575
574576##### stats
575577Type: ` Object `
0 commit comments