Skip to content

Commit

Permalink
Add task not completed warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
phated committed Nov 11, 2015
1 parent 62a7cae commit 92e0356
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/shared/cliOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ module.exports = {
count: true,
// Can't use `default` because it seems to be off by one
desc: chalk.gray(
'Set the loglevel. -L for least verbose and -LLLL for most verbose.' +
' -LLL is default.'),
'Set the loglevel. -L for least verbose and -LLLL for most verbose. ' +
'-LLL is default.'),
},
};
2 changes: 2 additions & 0 deletions lib/versioned/^4.0.0-alpha.1/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var exit = require('../../shared/exit');

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

function execute(opts, env) {
Expand All @@ -25,6 +26,7 @@ function execute(opts, env) {

var gulpInst = require(env.modulePath);
logEvents(gulpInst);
logSyncTask(gulpInst);

// This is what actually loads up the gulpfile
require(env.configPath);
Expand Down
44 changes: 44 additions & 0 deletions lib/versioned/^4.0.0-alpha.1/log/syncTask.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
'use strict';

var log = require('gulplog');
var chalk = require('chalk');

var tasks = {};

function warn() {
var taskKeys = Object.keys(tasks);

if (!taskKeys.length) {
return;
}

var taskNames = taskKeys.map(function(key) {
return tasks[key];
}).join(', ');

log.warn(
chalk.red('The following tasks did not complete:'),
chalk.cyan(taskNames)
);
log.warn(
chalk.red('Did you forget to signal async completion?')
);
}

function start(e) {
tasks[e.uid] = e.name;
}

function clear(e) {
delete tasks[e.uid];
}

function logSyncTask(gulpInst) {

process.once('exit', warn);
gulpInst.on('start', start);
gulpInst.on('stop', clear);
gulpInst.on('error', clear);
}

module.exports = logSyncTask;

0 comments on commit 92e0356

Please sign in to comment.