Skip to content

Commit

Permalink
DRY tasks.js
Browse files Browse the repository at this point in the history
  • Loading branch information
= authored and phated committed Nov 11, 2015
1 parent 0226d55 commit a8371e0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var archy = require('archy');
var chalk = require('chalk');
var gutil = require('gulp-util');

function logTasks(tree, tasks) {
function logTasks(tree, getDescription) {
var padding = 0;
archy(tree)
.split('\n')
Expand All @@ -31,7 +31,7 @@ function logTasks(tree, tasks) {
gutil.log(
line[0] + ' ' + chalk.cyan(task) +
Array(padding + 3 - v.length).join(' ') +
(tasks.get(task).description || '')
(getDescription(task) || '')
);
}
});
Expand Down
9 changes: 7 additions & 2 deletions lib/versioned/^3.7.0/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ var chalk = require('chalk');
var gutil = require('gulp-util');
var tildify = require('tildify');

var logTasks = require('./log/tasks');
var taskTree = require('./taskTree');
var logTasks = require('../../shared/log/tasks');
var logEvents = require('./log/events');
var logTasksSimple = require('./log/tasksSimple');

Expand All @@ -25,7 +26,11 @@ function execute(opts, env) {
return logTasksSimple(env, gulpInst);
}
if (opts.tasks) {
return logTasks(env, gulpInst);
var tree = taskTree(gulpInst.tasks);
tree.label = 'Tasks for ' + chalk.magenta(tildify(env.configPath));
return logTasks(tree, function(task) {
return gulpInst.tasks[task].fn.description;
});
}
gulpInst.start.apply(gulpInst, toRun);
});
Expand Down
45 changes: 0 additions & 45 deletions lib/versioned/^3.7.0/log/tasks.js

This file was deleted.

6 changes: 4 additions & 2 deletions lib/versioned/^4.0.0-alpha.1/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var tildify = require('tildify');

var exit = require('../../shared/exit');

var logTasks = require('./log/tasks');
var logTasks = require('../../shared/log/tasks');
var logEvents = require('./log/events');
var logTasksSimple = require('./log/tasksSimple');

Expand All @@ -30,7 +30,9 @@ function execute(opts, env) {
label: 'Tasks for ' + chalk.magenta(tildify(env.configPath)),
nodes: gulpInst.tree({ deep: true }),
};
return logTasks(tree, gulpInst);
return logTasks(tree, function(task) {
return gulpInst.get(task).description;
});
}
if (opts.tasksJson) {
return console.log(
Expand Down

0 comments on commit a8371e0

Please sign in to comment.