Skip to content

Commit

Permalink
Breaking: Remove array & string task support from gulp.watch
Browse files Browse the repository at this point in the history
  • Loading branch information
dinoboff authored and phated committed Dec 31, 2017
1 parent ad627e6 commit b085e95
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
18 changes: 7 additions & 11 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -487,14 +487,17 @@ Type: `Array`, `String` or `Function`
A task name, a function or an array of either.


### gulp.watch(glob[, opts], tasks)
### gulp.watch(glob[, opts], fn)

Watch files and do something when a file changes.

```js
gulp.watch('js/**/*.js', gulp.parallel('uglify', 'reload'));
```

In the example, `gulp.watch` runs the function returned by gulp.parallel each
time a file with the `js` extension in `js/` is updated.

#### glob
Type: `String` or `Array`

Expand All @@ -505,17 +508,10 @@ Type: `Object`

Options, that are passed to [`gaze`][gaze].

#### tasks
Type: `Array`, `Function` or `String`

A task name, a function or an array of either to run when a file changes.
#### fn
Type: `Function`

When `tasks` is an array, the tasks will be run in parallel:
```
gulp.watch('*.js', [one, two]);
// is equivalent to
gulp.watch('*.js', gulp.parallel(one, two));
```
An [async](#async-support) function to run when a file changes.

`gulp.watch` returns an `EventEmitter` object which emits `change` events with
the [gaze] `event`:
Expand Down
5 changes: 1 addition & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ util.inherits(Gulp, Undertaker);
Gulp.prototype.src = vfs.src;
Gulp.prototype.dest = vfs.dest;
Gulp.prototype.watch = function(glob, opt, task) {
var isFunction = (typeof opt === 'function');
var isString = (typeof opt === 'string');
var isArray = Array.isArray(opt);
if (isFunction || isString || isArray) {
if (typeof opt === 'function') {
task = opt;
opt = null;
}
Expand Down

0 comments on commit b085e95

Please sign in to comment.