<commit_before>'use strict';

var util = require('./lib/util');

exports = module.exports = gulpRepl;
exports.instances = [];

/**
 * create a readline interface
**/
var repl = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout,
  completer: function onCompletion(line){
    return util.completer(line, exports.instances);
  }
});

/**
 * queue tasks when line is not empty
**/
repl.on('line', function onLine(input){
  var line = input.trim();
  if(!line){ return repl.prompt(); }

  var queue = {
    found: [],
    notFound: line.split(/[ ]+/)
  };

  exports.instances.forEach(function(inst){
    var tasks = util.getQueue(queue.notFound.join(' '), inst.tasks);
    if(tasks.found.length){
      queue.found.push({
        inst: inst,
        tasks: tasks.found
      });
    }
    queue.notFound = tasks.notFound;
  });

  if(queue.notFound.length){
    var plural = queue.notFound.length > 1;
    console.log(' `%s` task%s %s not defined yet',
      queue.notFound.join(', '),
      plural ? 's' : '',
      plural ? 'are' : 'is'
    );
  } else {
    queue.found.forEach(function(found){
      var result = found.inst.runner.apply(found.inst.gulp, found.tasks);
      if(typeof result === 'function'){
        result(); // gulp#4.0
      }
    });
  }
});<commit_msg>fix: prompt after not found tasks<commit_after>'use strict';

var util = require('./lib/util');

exports = module.exports = gulpRepl;
exports.instances = [];

/**
 * create a readline interface
**/
var repl = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout,
  completer: function onCompletion(line){
    return util.completer(line, exports.instances);
  }
});

/**
 * queue tasks when line is not empty
**/
repl.on('line', function onLine(input){
  var line = input.trim();
  if(!line){ return repl.prompt(); }

  var queue = {
    found: [],
    notFound: line.split(/[ ]+/)
  };

  exports.instances.forEach(function(inst){
    var tasks = util.getQueue(queue.notFound.join(' '), inst.tasks);
    if(tasks.found.length){
      queue.found.push({
        inst: inst,
        tasks: tasks.found
      });
    }
    queue.notFound = tasks.notFound;
  });

  if(queue.notFound.length){
    var plural = queue.notFound.length > 1;

    console.log(' `%s` task%s %s not defined yet',
      queue.notFound.join(', '),
      plural ? 's' : '',
      plural ? 'are' : 'is'
    );

    return repl.prompt();
  }

  queue.found.forEach(function(found){
    var result = found.inst.runner.apply(found.inst.gulp, found.tasks);
    if(typeof result === 'function'){
      result(); // gulp#4.0
    }
  });
});
{'fraction_non_alphanumeric': 0.17724867724867724, 'fraction_numerical': 0.0022675736961451248, 'mean_word_length': 2.909896602658789, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1473492', 'n_tokens_mistral': 889, 'n_tokens_neox': 878, 'n_words': 184}