Docs: Add default task wrappers to Watching Files examples to make ru… · gulpjs/gulp@d916276
@@ -29,10 +29,12 @@ function css(cb) {
2929cb();
3030}
313132-// You can use a single task
33-watch('src/*.css', css);
34-// Or a composed task
35-watch('src/*.js', series(clean, javascript));
32+exports.default = function() {
33+// You can use a single task
34+watch('src/*.css', css);
35+// Or a composed task
36+watch('src/*.js', series(clean, javascript));
37+};
3638```
37393840## Warning: avoid synchronous
@@ -49,11 +51,13 @@ If you need to use different events, you can use the `events` option when callin
4951```js
5052const { watch } = require('gulp');
515352-// All events will be watched
53-watch('src/*.js', { events: 'all' }, function(cb) {
54-// body omitted
55-cb();
56-});
54+exports.default = function() {
55+// All events will be watched
56+watch('src/*.js', { events: 'all' }, function(cb) {
57+// body omitted
58+cb();
59+ });
60+};
5761```
58625963## Initial execution
@@ -65,11 +69,13 @@ To execute tasks before the first file change, set the `ignoreInitial` option to
6569```js
6670const { watch } = require('gulp');
677168-// The task will be executed upon startup
69-watch('src/*.js', { ignoreInitial: false }, function(cb) {
70-// body omitted
71-cb();
72-});
72+exports.default = function() {
73+// The task will be executed upon startup
74+watch('src/*.js', { ignoreInitial: false }, function(cb) {
75+// body omitted
76+cb();
77+ });
78+};
7379```
74807581## Queueing
@@ -81,11 +87,13 @@ To disable queueing, set the `queue` option to `false`.
8187```js
8288const { watch } = require('gulp');
838984-// The task will be run (concurrently) for every change made
85-watch('src/*.js', { queue: false }, function(cb) {
86-// body omitted
87-cb();
88-});
90+exports.default = function() {
91+// The task will be run (concurrently) for every change made
92+watch('src/*.js', { queue: false }, function(cb) {
93+// body omitted
94+cb();
95+ });
96+};
8997```
90989199## Delay
@@ -97,11 +105,13 @@ To adjust the delay duration, set the `delay` option to a positive integer.
97105```js
98106const { watch } = require('gulp');
99107100-// The task won't be run until 500ms have elapsed since the first change
101-watch('src/*.js', { delay: 500 }, function(cb) {
102-// body omitted
103-cb();
104-});
108+exports.default = function() {
109+// The task won't be run until 500ms have elapsed since the first change
110+watch('src/*.js', { delay: 500 }, function(cb) {
111+// body omitted
112+cb();
113+ });
114+};
105115```
106116107117## Using the watcher instance