forked from totolicious/gulp-task-list
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
40 lines (37 loc) · 1.18 KB
/
index.js
File metadata and controls
40 lines (37 loc) · 1.18 KB
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
'use strict';
var fs = require('graceful-fs'); // use just like fs
var gutil = require('gulp-util');
var clitable = require('cli-table');
module.exports = function(gulp) {
gulp.task('task-list', function() {
var gulpfile = fs.readFileSync('gulpfile.js').toString();
var table = new clitable({
head: ['Task Name', 'Description', 'Dependencies'],
chars: {
'top': '' , 'top-mid': '' , 'top-left': '' , 'top-right': '',
'bottom': '' , 'bottom-mid': '' , 'bottom-left': '' , 'bottom-right': '',
'left': '' , 'left-mid': '' , 'mid': '' , 'mid-mid': '',
'right': '' , 'right-mid': '' , 'middle': ' '
}
});
var start, end, comment, deps;
for (var gulptask in gulp.tasks) {
if (gulp.tasks.hasOwnProperty(gulptask)) {
if (gulptask == 'task-list') {
continue;
}
start = gulpfile.lastIndexOf("//", gulpfile.indexOf(gulptask));
end = gulpfile.indexOf('\n', start);
if (start !== -1 && end !== -1) {
start += 2;
comment = gulpfile.substring(start, end);
} else {
comment = "";
}
deps = gulp.tasks[gulptask].dep.join(", ");
table.push([gulptask, comment, deps]);
}
}
console.log(table.toString());
});
};