gulp-help-doc
Advanced tools
Comparing version 1.0.4 to 1.0.5
55
index.js
@@ -20,2 +20,7 @@ /** | ||
/** | ||
* @external Gulp | ||
* @see {@link https://github.com/gulpjs/gulp/blob/master/docs/API.md} | ||
*/ | ||
/** | ||
* Gulpfile reflection metadata | ||
@@ -54,7 +59,42 @@ * | ||
/** | ||
* @external Gulp | ||
* @see {@link https://github.com/gulpjs/gulp/blob/master/docs/API.md} | ||
*/ | ||
function rdeps(nodes) { | ||
var deps = []; | ||
if (!nodes.length) return deps; | ||
nodes.forEach(function(node) { | ||
if (!node.branch) { | ||
deps.push(node.label); | ||
} | ||
deps = deps.concat(rdeps(node.nodes)); | ||
}); | ||
return deps.reduce(function(p, c) { | ||
if (p.indexOf(c) < 0) p.push(c); | ||
return p; | ||
}, []); | ||
} | ||
function gulpTasks(gulp) { | ||
if (!gulp.tree) { | ||
// old gulp | ||
return gulp.tasks; | ||
} | ||
// v4 | ||
var nodes = gulp.tree({ deep: true }).nodes; | ||
var tasks = {}; | ||
nodes.forEach(function(node) { | ||
tasks[node.label] = { | ||
name: node.label, | ||
dep: rdeps(node.nodes) | ||
}; | ||
}); | ||
return tasks; | ||
} | ||
/** | ||
@@ -77,8 +117,9 @@ * Analyzes given gulp instance and build internal cache | ||
var jsDoc = source.match(globalRxDoc); | ||
var tasks = gulpTasks(gulp); | ||
Object.keys(gulp.tasks).forEach(function (task) { | ||
Object.keys(tasks).forEach(function (task) { | ||
reflection[task] = { | ||
name: gulp.tasks[task].name, | ||
name: tasks[task].name, | ||
desc: '', | ||
dep: gulp.tasks[task].dep | ||
dep: tasks[task].dep | ||
}; | ||
@@ -85,0 +126,0 @@ }); |
{ | ||
"name": "gulp-help-doc", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Gulp available tasks usage information based on jsdoc-like notations", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# gulp-help-doc | ||
[](https://travis-ci.org/Mikhus/gulp-help-doc) | ||
[](https://travis-ci.org/Mikhus/gulp-help-doc) [](https://raw.githubusercontent.com/Mikhus/gulp-help-doc/master/LICENSE) | ||
@@ -4,0 +4,0 @@ Self-documented gulp tasks with pretty printable usage information in command-line. |
Sorry, the diff of this file is not supported yet
15675
322