forked from gulpjs/gulp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
60 lines (48 loc) · 1.69 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*jshint node:true */
"use strict";
var util = require('util');
var Orchestrator = require('orchestrator');
var gutil = require('gulp-util');
// format orchestrator errors
var formatError = function(e) {
if (!e.err) return e.message;
if (e.err.message) return e.err.message;
return JSON.stringify(e.err);
};
function Gulp(){
Orchestrator.call(this);
this.env = {};
// Logging
this.on('task_start', function(e){
gutil.log('Running', "'"+gutil.colors.cyan(e.task)+"'...");
});
this.on('task_stop', function(e){
var time = gutil.prettyTime(e.duration);
gutil.log('Finished', "'"+gutil.colors.cyan(e.task)+"'", "in", gutil.colors.magenta(time.value), time.shortUnit);
});
this.on('task_err', function(e){
var msg = formatError(e);
var time = gutil.prettyTime(e.duration);
gutil.log('Errored', "'"+gutil.colors.cyan(e.task)+"'", "in", gutil.colors.magenta(time.value), time.shortUnit, gutil.colors.red(msg));
});
}
util.inherits(Gulp, Orchestrator);
Gulp.prototype.taskQueue = Gulp.prototype.seq;
Gulp.prototype.task = Gulp.prototype.add;
Gulp.prototype.run = function(){
var tasks = Array.prototype.slice.call(arguments);
// impose our opinion of "default" tasks onto orchestrator
if (!tasks.length) {
tasks = ['default'];
}
this.start.apply(this, tasks);
};
Gulp.prototype.src = require('./lib/createInputStream');
Gulp.prototype.dest = require('./lib/createOutputStream');
Gulp.prototype.watch = require('./lib/watchFile');
Gulp.prototype.formatFile = require('./lib/formatFile');
Gulp.prototype.bufferFile = require('./lib/bufferFile');
Gulp.prototype.streamFile = require('./lib/streamFile');
var gulp = new Gulp();
gulp.Gulp = Gulp;
module.exports = gulp;