'use strict';

var util = require('util');
var Undertaker = require('undertaker');
var vfs = require('vinyl-fs');
var chokidar = require('chokidar');

function Gulp() {
  Undertaker.call(this);
}
util.inherits(Gulp, Undertaker);

Gulp.prototype.src = vfs.src;
Gulp.prototype.dest = vfs.dest;
Gulp.prototype.symlink = vfs.symlink;
Gulp.prototype.watch = function(glob, opt, task) {
  if (typeof opt === 'string' || typeof task === 'string' ||
    Array.isArray(opt) || Array.isArray(task)) {
    throw new Error('watching ' + glob + ': watch task has to be ' +
      'a function (optionally generated by using gulp.parallel ' +
      'or gulp.series)');
  }

  if (typeof opt === 'function') {
    task = opt;
    opt = null;
  }

  var fn;
  if (typeof task === 'function') {
    fn = this.parallel(task);
  }

  var watcher = chokidar.watch(glob, opt);
  if (fn) {
    watcher
      .on('change', fn)
      .on('unlink', fn)
      .on('add', fn);
  }

  return watcher;
};

// Let people use this class from our instance
Gulp.prototype.Gulp = Gulp;

var inst = new Gulp();
module.exports = inst;

'use strict';

var util = require('util');
var Undertaker = require('undertaker');
var vfs = require('vinyl-fs');
var chokidar = require('chokidar');

function Gulp() {
  Undertaker.call(this);
}
util.inherits(Gulp, Undertaker);

Gulp.prototype.src = vfs.src;
Gulp.prototype.dest = vfs.dest;
Gulp.prototype.symlink = vfs.symlink;
Gulp.prototype.watch = function(glob, opt, task) {
  if (typeof opt === 'string' || typeof task === 'string' ||
    Array.isArray(opt) || Array.isArray(task)) {
    throw new Error('watching ' + glob + ': watch task has to be ' +
      'a function (optionally generated by using gulp.parallel ' +
      'or gulp.series)');
  }

  if (typeof opt === 'function') {
    task = opt;
    opt = {};
  }

  var fn;
  if (typeof task === 'function') {
    fn = this.parallel(task);
  }

  if (opt.ignoreInitial == null) {
    opt.ignoreInitial = true;
  }

  var watcher = chokidar.watch(glob, opt);
  if (fn) {
    watcher
      .on('change', fn)
      .on('unlink', fn)
      .on('add', fn);
  }

  return watcher;
};

// Let people use this class from our instance
Gulp.prototype.Gulp = Gulp;

var inst = new Gulp();
module.exports = inst;

Set chokidar option ignoreIntial: true by default
Fix: Set chokidar option ignoreIntial: true by default
