Skip to content

Commit

Permalink
Merge pull request #46 from gulpjs/track-logged-errors
Browse files Browse the repository at this point in the history
Track logged errors
  • Loading branch information
phated committed Dec 18, 2015
2 parents 5e121b6 + af74029 commit ce7ae38
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
3 changes: 1 addition & 2 deletions lib/versioned/^4.0.0-alpha.1/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ function execute(opts, env) {
var output = JSON.stringify(gulpInst.tree({ deep: true }));
if (typeof opts.tasksJson === 'boolean' && opts.tasksJson) {
return console.log(output);
} else {
return fs.writeFileSync(opts.tasksJson, output, 'utf-8');
}
return fs.writeFileSync(opts.tasksJson, output, 'utf-8');
}
try {
log.info('Using gulpfile', chalk.magenta(tildify(env.configPath)));
Expand Down
3 changes: 1 addition & 2 deletions lib/versioned/^4.0.0-alpha.2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ function execute(opts, env) {

if (typeof opts.tasksJson === 'boolean' && opts.tasksJson) {
return console.log(output);
} else {
return fs.writeFileSync(opts.tasksJson, output, 'utf-8');
}
return fs.writeFileSync(opts.tasksJson, output, 'utf-8');
}
try {
log.info('Using gulpfile', chalk.magenta(tildify(env.configPath)));
Expand Down
3 changes: 1 addition & 2 deletions lib/versioned/^4.0.0/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ function execute(opts, env) {

if (typeof opts.tasksJson === 'boolean' && opts.tasksJson) {
return console.log(output);
} else {
return fs.writeFileSync(opts.tasksJson, output, 'utf-8');
}
return fs.writeFileSync(opts.tasksJson, output, 'utf-8');
}
try {
log.info('Using gulpfile', chalk.magenta(tildify(env.configPath)));
Expand Down
27 changes: 17 additions & 10 deletions lib/versioned/^4.0.0/log/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,36 @@ var formatError = require('../formatError');
// Wire up logging events
function logEvents(gulpInst) {

gulpInst.on('start', function(e) {
var loggedErrors = [];

gulpInst.on('start', function(evt) {
// TODO: batch these
// so when 5 tasks start at once it only logs one time with all 5
log.info('Starting', '\'' + chalk.cyan(e.name) + '\'...');
log.info('Starting', '\'' + chalk.cyan(evt.name) + '\'...');
});

gulpInst.on('stop', function(e) {
var time = prettyTime(e.duration);
gulpInst.on('stop', function(evt) {
var time = prettyTime(evt.duration);
log.info(
'Finished', '\'' + chalk.cyan(e.name) + '\'',
'Finished', '\'' + chalk.cyan(evt.name) + '\'',
'after', chalk.magenta(time)
);
});

gulpInst.on('error', function(e) {
var msg = formatError(e);
var time = prettyTime(e.duration);
gulpInst.on('error', function(evt) {
var msg = formatError(evt);
var time = prettyTime(evt.duration);
log.error(
'\'' + chalk.cyan(e.name) + '\'',
'\'' + chalk.cyan(evt.name) + '\'',
chalk.red('errored after'),
chalk.magenta(time)
);
log.error(msg);

// If we haven't logged this before, log it and add to list
if (loggedErrors.indexOf(evt.error) === -1) {
log.error(msg);
loggedErrors.push(evt.error);
}
});
}

Expand Down

0 comments on commit ce7ae38

Please sign in to comment.