UNPKG

1.52 kBJavaScriptView Raw
1'use strict';
2
3var util = require('util');
4var Orchestrator = require('orchestrator');
5var gutil = require('gulp-util');
6var deprecated = require('deprecated');
7var vfs = require('vinyl-fs');
8
9function Gulp() {
10 Orchestrator.call(this);
11}
12util.inherits(Gulp, Orchestrator);
13
14Gulp.prototype.task = Gulp.prototype.add;
15Gulp.prototype.run = function () {
16 // run() is deprecated as of 3.5 and will be removed in 4.0
17 // use task dependencies instead
18
19 // impose our opinion of "default" tasks onto orchestrator
20 var tasks = arguments.length ? arguments : ['default'];
21
22 this.start.apply(this, tasks);
23};
24
25Gulp.prototype.src = vfs.src;
26Gulp.prototype.dest = vfs.dest;
27Gulp.prototype.watch = function (glob, opt, fn) {
28 if (typeof opt === 'function' || Array.isArray(opt)) {
29 fn = opt;
30 opt = null;
31 }
32
33 // array of tasks given
34 if (Array.isArray(fn)) {
35 return vfs.watch(glob, opt, function () {
36 this.start.apply(this, fn);
37 }.bind(this));
38 }
39
40 return vfs.watch(glob, opt, fn);
41};
42
43// let people use this class from our instance
44Gulp.prototype.Gulp = Gulp;
45
46// deprecations
47deprecated.field('gulp.env has been deprecated. ' +
48 'Use your own CLI parser instead. ' +
49 'We recommend using yargs or minimist.',
50 console.warn,
51 Gulp.prototype,
52 'env',
53 gutil.env
54);
55
56Gulp.prototype.run = deprecated.method('gulp.run() has been deprecated. ' +
57 'Use task dependencies or gulp.watch task triggering instead.',
58 console.warn,
59 Gulp.prototype.run
60);
61
62var inst = new Gulp();
63module.exports = inst;