Skip to content

Commit

Permalink
Merge 156f625 into 348d6fd
Browse files Browse the repository at this point in the history
  • Loading branch information
dinoboff committed Mar 25, 2015
2 parents 348d6fd + 156f625 commit d70b911
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
Expand Up @@ -458,14 +458,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 @@ -476,17 +479,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
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 d70b911

Please sign in to comment.