<commit_before>'use strict';

var util = require('runtime/lib/utils');
var runtime = require('runtime').get('gulp');

module.exports = taskStatus;

//
// ## function `taskStatus`
// mirror gulp's `logEvents` to gather information
//

function taskStatus(gulpInst){

  var status = { task : { }, done : false, current : { } };
  var statusMap = {
        'task_start' : 'start',
         'task_stop' : 'done',
         'task_err'  : 'error',
     'task_no_found' : 'notFound'
  };

  Object.keys(statusMap).forEach(function(eventName){

    var statusName = statusMap[eventName];

    var onStart = eventName.match(/start/);
    var onError = eventName.match(/err/);
    var onStop = eventName.match(/stop|err/);
    var onNotFound = eventName.match(/not_found/);

    gulpInst.on(eventName, function(taskEvent){

      var e = taskEvent;
      e[statusName] = true;

      e.dep = gulpInst.tasks[e.task].dep;

      if( onStop || onError || onNotFound ){

        delete e.start;
        e.time = util.prettyTime(e.hrDuration);

        status.done = true;
        if( e.dep[0] ){

          var done = status.done;
          var task = status.task;
          e.dep.forEach(function(dep){
            status.done = done && task[dep].done;
          });
          status.done = done;
        } else {
          delete e.dep;
        }
      }

      if( onError ){
        e.message = util.formatError(e);
      }

      if( onStart ){
        status.done = false;
      }

      status.task[e.task] = e;
      status.current = e;
      var copy = util.merge({ }, status);
      runtime.emit('status', copy);
    });
  });
}<commit_msg>0.3.0 - status is just a simple listener for gulp loggin<commit_after>'use strict';

var util = require('runtime/lib/utils');
var runtime = require('runtime').get('gulp');

module.exports = taskStatus;

//
// ## function `taskStatus`
// mirror gulp's `logEvents` to gather information
//

function taskStatus(gulpInst){
  var statusMap = {
        'task_start' : 'start',
         'task_stop' : 'done',
         'task_err'  : 'error',
     'task_no_found' : 'notFound'
  };
  Object.keys(statusMap).forEach(function(eventName){
    gulpInst.on(eventName, function(taskEvent){
      runtime.emit('status', taskEvent);
    });
  });
}
{'fraction_non_alphanumeric': 0.15703573003970003, 'fraction_numerical': 0.00176444640494045, 'mean_word_length': 2.4259818731117826, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2094115', 'n_tokens_mistral': 744, 'n_tokens_neox': 725, 'n_words': 150}