From 72732753602a2680d225b90c2290db22afe7ac8d Mon Sep 17 00:00:00 2001 From: Javier Carrillo Date: Sat, 11 Feb 2017 19:09:02 +0100 Subject: [PATCH 1/2] fix: logging for task parameters Depth was preventing to log the correct values fixes #25 --- index.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/index.js b/index.js index 1b92a15..1288053 100644 --- a/index.js +++ b/index.js @@ -112,9 +112,10 @@ Gulp.prototype.tree = function (stack, options) { if (options.simple) { return tasks; } } - var tree = {label: options.label || '', nodes: []}; - var depth = options.depth === void 0 || options.depth; - if (depth && typeof depth !== 'number') { depth = 1; } + var tree = { + label: options.label || '', + nodes: [] + }; tasks.forEach(function (task) { if (!task || !task.fn) { return; } @@ -122,12 +123,11 @@ Gulp.prototype.tree = function (stack, options) { if (Array.isArray(task.fn.stack)) { node = self.tree(task.fn.stack, { - host: task, - depth: depth && (depth + 1) || false + host: task }); } else { node = { - label: depth == 1 && (task.match || task.name) || task.name + label: task.match || task.name }; } @@ -188,12 +188,11 @@ Gulp.prototype.onHandleStart = function (task, stack) { if (!stack.time) { stack.time = process.hrtime(); stack.label = this.tree(stack).label; + } - if (Array.isArray(task.fn && task.fn.stack) && task.fn.stack.props) { - stack.match = task.match || task.name || task.displayName; - stack.siteProps = task.fn.stack.props; - } - + if (Array.isArray(task.fn && task.fn.stack) && task.fn.stack.props) { + stack.match = task.match || task.name || task.displayName; + stack.siteProps = task.fn.stack.props; util.log('Start', util.format.task(stack)); } From 5707c9cb7086c75912fe2d3bcf54f4322b363b98 Mon Sep 17 00:00:00 2001 From: Javier Carrillo Date: Sat, 11 Feb 2017 19:09:28 +0100 Subject: [PATCH 2/2] docs: add example to test logging --- examples/task-parameter-logging.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 examples/task-parameter-logging.js diff --git a/examples/task-parameter-logging.js b/examples/task-parameter-logging.js new file mode 100644 index 0000000..8c06912 --- /dev/null +++ b/examples/task-parameter-logging.js @@ -0,0 +1,9 @@ +'use strict'; + +var gulp = require('../.').create(); + +gulp.task(':one', function (done) { + setTimeout(done, 120); +}); + +gulp.task('default', gulp.series('one', 'two'));