1 | 'use strict';
|
2 |
|
3 |
|
4 | var colors = require('colors');
|
5 |
|
6 |
|
7 | module.exports = function (gulp) {
|
8 |
|
9 | var originalTaskFn = gulp.task;
|
10 |
|
11 | gulp.task = function(name, help, dep, fn) {
|
12 |
|
13 |
|
14 | if (typeof help === 'function') {
|
15 |
|
16 | fn = undefined;
|
17 | dep = help;
|
18 | help = undefined;
|
19 | } else if (Array.isArray(help) && typeof dep === 'function') {
|
20 |
|
21 | fn = dep;
|
22 | dep = help;
|
23 | help = undefined;
|
24 | } else if (typeof dep === 'function') {
|
25 |
|
26 |
|
27 | } else if (Array.isArray(dep)) {
|
28 |
|
29 |
|
30 | } else {
|
31 |
|
32 | return originalTaskFn.call(gulp, name, help, dep, fn);
|
33 | }
|
34 |
|
35 |
|
36 | originalTaskFn.call(gulp, name, dep, fn);
|
37 | gulp.tasks[name].help = help;
|
38 | };
|
39 |
|
40 | gulp.task('help', 'Display this help text', function () {
|
41 | var tasks = Object.keys(gulp.tasks).sort();
|
42 |
|
43 | console.log('');
|
44 | console.log('Usage:'.underline);
|
45 | console.log(' gulp [task]');
|
46 | console.log('');
|
47 | console.log('Available tasks:'.underline);
|
48 | tasks.forEach(function(name) {
|
49 | var helpText = gulp.tasks[name].help || '';
|
50 | console.log(' ', name.cyan, helpText);
|
51 | });
|
52 | console.log('');
|
53 | });
|
54 | }; |
\ | No newline at end of file |