Skip to content

Commit fce78cc

Browse files
committed
New: Add "task not completed" warnings
1 parent 8f74ee1 commit fce78cc

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

lib/shared/cliOptions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ module.exports = {
8787
count: true,
8888
// Can't use `default` because it seems to be off by one
8989
desc: chalk.gray(
90-
'Set the loglevel. -L for least verbose and -LLLL for most verbose.' +
91-
' -LLL is default.'),
90+
'Set the loglevel. -L for least verbose and -LLLL for most verbose. ' +
91+
'-LLL is default.'),
9292
},
9393
};

lib/versioned/^4.0.0-alpha.1/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ var exit = require('../../shared/exit');
1111

1212
var logTasks = require('../../shared/log/tasks');
1313
var logEvents = require('./log/events');
14+
var logSyncTask = require('./log/syncTask');
1415
var logTasksSimple = require('./log/tasksSimple');
1516

1617
function execute(opts, env) {
@@ -25,6 +26,7 @@ function execute(opts, env) {
2526

2627
var gulpInst = require(env.modulePath);
2728
logEvents(gulpInst);
29+
logSyncTask(gulpInst);
2830

2931
// This is what actually loads up the gulpfile
3032
require(env.configPath);
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
'use strict';
2+
3+
var log = require('gulplog');
4+
var chalk = require('chalk');
5+
6+
var tasks = {};
7+
8+
function warn() {
9+
var taskKeys = Object.keys(tasks);
10+
11+
if (!taskKeys.length) {
12+
return;
13+
}
14+
15+
var taskNames = taskKeys.map(function(key) {
16+
return tasks[key];
17+
}).join(', ');
18+
19+
log.warn(
20+
chalk.red('The following tasks did not complete:'),
21+
chalk.cyan(taskNames)
22+
);
23+
log.warn(
24+
chalk.red('Did you forget to signal async completion?')
25+
);
26+
}
27+
28+
function start(e) {
29+
tasks[e.uid] = e.name;
30+
}
31+
32+
function clear(e) {
33+
delete tasks[e.uid];
34+
}
35+
36+
function logSyncTask(gulpInst) {
37+
38+
process.once('exit', warn);
39+
gulpInst.on('start', start);
40+
gulpInst.on('stop', clear);
41+
gulpInst.on('error', clear);
42+
}
43+
44+
module.exports = logSyncTask;

0 commit comments

Comments
 (0)