1 | 'use strict';
|
2 |
|
3 | var util = require('util');
|
4 | var Undertaker = require('undertaker');
|
5 | var vfs = require('vinyl-fs');
|
6 | var watch = require('glob-watcher');
|
7 |
|
8 | function Gulp() {
|
9 | Undertaker.call(this);
|
10 |
|
11 |
|
12 | this.watch = this.watch.bind(this);
|
13 | this.task = this.task.bind(this);
|
14 | this.series = this.series.bind(this);
|
15 | this.parallel = this.parallel.bind(this);
|
16 | this.registry = this.registry.bind(this);
|
17 | this.tree = this.tree.bind(this);
|
18 | this.lastRun = this.lastRun.bind(this);
|
19 | this.src = this.src.bind(this);
|
20 | this.dest = this.dest.bind(this);
|
21 | this.symlink = this.symlink.bind(this);
|
22 | }
|
23 | util.inherits(Gulp, Undertaker);
|
24 |
|
25 | Gulp.prototype.src = vfs.src;
|
26 | Gulp.prototype.dest = vfs.dest;
|
27 | Gulp.prototype.symlink = vfs.symlink;
|
28 | Gulp.prototype.watch = function(glob, opt, task) {
|
29 | if (typeof opt === 'string' || typeof task === 'string' ||
|
30 | Array.isArray(opt) || Array.isArray(task)) {
|
31 | throw new Error('watching ' + glob + ': watch task has to be ' +
|
32 | 'a function (optionally generated by using gulp.parallel ' +
|
33 | 'or gulp.series)');
|
34 | }
|
35 |
|
36 | if (typeof opt === 'function') {
|
37 | task = opt;
|
38 | opt = {};
|
39 | }
|
40 |
|
41 | opt = opt || {};
|
42 |
|
43 | var fn;
|
44 | if (typeof task === 'function') {
|
45 | fn = this.parallel(task);
|
46 | }
|
47 |
|
48 | return watch(glob, opt, fn);
|
49 | };
|
50 |
|
51 |
|
52 | Gulp.prototype.Gulp = Gulp;
|
53 |
|
54 | var inst = new Gulp();
|
55 | module.exports = inst;
|