forked from gulpjs/gulp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
67 lines (54 loc) · 1.77 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
61
62
63
64
65
66
67
/*jshint node:true */
"use strict";
var util = require('util');
var Orchestrator = require('orchestrator');
var chalk = require('chalk');
// 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){
gulp.log('Running', "'"+chalk.cyan(e.task)+"'...");
});
this.on('task_stop', function(e){
gulp.log('Finished', "'"+chalk.cyan(e.task)+"' in "+chalk.magenta(e.duration)+" seconds");
});
this.on('task_err', function(e){
var msg = formatError(e);
gulp.log('Errored', "'"+chalk.cyan(e.task)+"' in "+chalk.magenta(e.duration)+" seconds "+chalk.red(msg));
});
}
util.inherits(Gulp, Orchestrator);
Gulp.prototype.log = function(){
if (this.env.silent) return;
var sig = '['+chalk.green('gulp')+']';
var args = Array.prototype.slice.call(arguments);
args.unshift(sig);
console.log.apply(console, args);
return this;
};
Gulp.prototype.taskQueue = Gulp.prototype.seq;
Gulp.prototype.task = Gulp.prototype.add;
Gulp.prototype.run = function(){
var tasks = Array.prototype.slice.call(arguments);
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.createGlobStream = require('glob-stream').create;
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;