1 | 'use strict';
|
2 |
|
3 | var gutil = require('gulp-util');
|
4 |
|
5 | module.exports = function (gulp) {
|
6 |
|
7 | var originalTaskFn = gulp.task;
|
8 |
|
9 | gulp.task = function (name, help, dep, fn) {
|
10 |
|
11 | var task;
|
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 | task = gulp.tasks[name];
|
38 | if (task) {
|
39 | task.help = help;
|
40 | }
|
41 | };
|
42 |
|
43 | gulp.task('help', 'Display this help text', function () {
|
44 | var tasks = Object.keys(gulp.tasks).sort();
|
45 |
|
46 | console.log('');
|
47 | console.log(gutil.colors.underline('Usage:'));
|
48 | console.log(' gulp [task]');
|
49 | console.log('');
|
50 | console.log(gutil.colors.underline('Available tasks:'));
|
51 | tasks.forEach(function (name) {
|
52 | var helpText = gulp.tasks[name].help || '';
|
53 | console.log(' ', gutil.colors.cyan(name), helpText);
|
54 | });
|
55 | console.log('');
|
56 | });
|
57 | }; |
\ | No newline at end of file |