<commit_before>var Console = require('./console');
var FileManager = require('./files');
var chalk = require('chalk');
var path = require('path');
var exit = require('exit');

function Flow(options){
  this.startTime = Date.now();
  this.options = options;
  this.warns = [];
  this.console = new Console();

  var baseURI = options.base;
  var relBaseURI = path.dirname(path.relative(options.base, options.file));
  this.files = new FileManager(baseURI, relBaseURI, this.console, this);
}

Flow.prototype = {
  exitOnFatal: false,

  time: function(){
    return Date.now() - this.startTime;
  },
  warn: function(warn){
    this.warns.push(warn);

    if (warn.fatal)
    {
      var enabled = this.console.enabled;

      if (this.exitOnFatal)
        this.console.resetDeep();

      this.console.enabled = true;
      this.console.log.apply(this.console, [chalk.red('[FATAL]')].concat(warn.message));
      this.console.enabled = enabled;

      if (this.exitOnFatal)
        exit(2);
    }
    else
    {
      this.console.log.apply(this.console, [chalk.red('[WARN]')].concat(warn.message));
    }
  },
  removeWarn: function(warn){
    var idx = this.warns.indexOf(warn);
    if (idx != -1)
      this.warns.splice(idx, 1);
  },
  hasWarn: function(warn){
    return this.warns.some(function(flowWarn){
      return warn.fatal == flowWarn.fatal &&
             warn.file == flowWarn.file &&
             warn.loc == flowWarn.loc &&
             warn.message == flowWarn.message;
    });
  }
};

module.exports = Flow;<commit_msg>output fatal warning when console disabled only if Flow#exitOnFatal enabled<commit_after>var Console = require('./console');
var FileManager = require('./files');
var chalk = require('chalk');
var path = require('path');
var exit = require('exit');

function Flow(options){
  this.startTime = Date.now();
  this.options = options;
  this.warns = [];
  this.console = new Console();

  var baseURI = options.base;
  var relBaseURI = path.dirname(path.relative(options.base, options.file));
  this.files = new FileManager(baseURI, relBaseURI, this.console, this);
}

Flow.prototype = {
  exitOnFatal: false,

  time: function(){
    return Date.now() - this.startTime;
  },
  warn: function(warn){
    this.warns.push(warn);

    if (warn.fatal)
    {
      if (this.exitOnFatal)
      {
        this.console.resetDeep();
        this.console.enabled = true;
      }

      this.console.log.apply(this.console, [chalk.red('[FATAL]')].concat(warn.message));

      if (this.exitOnFatal)
        exit(2);
    }
    else
    {
      this.console.log.apply(this.console, [chalk.red('[WARN]')].concat(warn.message));
    }
  },
  removeWarn: function(warn){
    var idx = this.warns.indexOf(warn);
    if (idx != -1)
      this.warns.splice(idx, 1);
  },
  hasWarn: function(warn){
    return this.warns.some(function(flowWarn){
      return warn.fatal == flowWarn.fatal &&
             warn.file == flowWarn.file &&
             warn.loc == flowWarn.loc &&
             warn.message == flowWarn.message;
    });
  }
};

module.exports = Flow;
{'fraction_non_alphanumeric': 0.16173120728929385, 'fraction_numerical': 0.0019524894240156199, 'mean_word_length': 2.891139240506329, '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': '2051519', 'n_tokens_mistral': 1019, 'n_tokens_neox': 1003, 'n_words': 191}