From 92e03568d3178f947caa1f2355385c21b4719bdf Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Mon, 21 Sep 2015 17:45:52 -0700 Subject: [PATCH] Add task not completed warnings --- lib/shared/cliOptions.js | 4 +- lib/versioned/^4.0.0-alpha.1/index.js | 2 + lib/versioned/^4.0.0-alpha.1/log/syncTask.js | 44 ++++++++++++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 lib/versioned/^4.0.0-alpha.1/log/syncTask.js diff --git a/lib/shared/cliOptions.js b/lib/shared/cliOptions.js index 2d54a5d0..077a470f 100644 --- a/lib/shared/cliOptions.js +++ b/lib/shared/cliOptions.js @@ -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.'), }, }; diff --git a/lib/versioned/^4.0.0-alpha.1/index.js b/lib/versioned/^4.0.0-alpha.1/index.js index 3cb63400..4e5c1715 100644 --- a/lib/versioned/^4.0.0-alpha.1/index.js +++ b/lib/versioned/^4.0.0-alpha.1/index.js @@ -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) { @@ -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); diff --git a/lib/versioned/^4.0.0-alpha.1/log/syncTask.js b/lib/versioned/^4.0.0-alpha.1/log/syncTask.js new file mode 100644 index 00000000..493654fc --- /dev/null +++ b/lib/versioned/^4.0.0-alpha.1/log/syncTask.js @@ -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;