<commit_before>const execFile = require('child_process').execFile;
const output = require('friendly-errors-webpack-plugin/src/output');

module.exports = class FlowCompilerPlugin {
  constructor(app, options) {
    this.app = app;
    this.options = options;
    this.promise = new Promise(() => {});
  }

  apply(compiler) {
    this.promise = this.flowCheckTypes();
    compiler.plugin('after-emit', (compilation, callback) => {
      this.promise.then((res) => {
        if (res.error) {
          output.title('info', 'FLOW ERROR', 'There was a flow type error');
          output.log(res.out);
        } else {
          output.title('success', 'FLOW SUCCESS', 'No type errors found');
        }
        // eventually we will could provide the option to fail the build
        // when flow fails
        callback();
      });
    });
    compiler.plugin('invalid', () => {
      this.promise = this.flowCheckTypes();
    });
  }

  flowCheckTypes() {
    return new Promise((resolve) => {
      execFile(
        require('flow-bin'),
        [this.app.path, '--show-all-errors'],
        (error, out) => {
          resolve({
            out,<commit_msg>Ignore rule<commit_after>const execFile = require('child_process').execFile;
const output = require('friendly-errors-webpack-plugin/src/output');

module.exports = class FlowCompilerPlugin {
  constructor(app, options) {
    this.app = app;
    this.options = options;
    this.promise = new Promise(() => {});
  }

  apply(compiler) {
    this.promise = this.flowCheckTypes();
    compiler.plugin('after-emit', (compilation, callback) => {
      this.promise.then((res) => {
        if (res.error) {
          output.title('info', 'FLOW ERROR', 'There was a flow type error');
          output.log(res.out);
        } else {
          output.title('success', 'FLOW SUCCESS', 'No type errors found');
        }
        // eventually we will could provide the option to fail the build
        // when flow fails
        callback();
      });
    });
    compiler.plugin('invalid', () => {
      this.promise = this.flowCheckTypes();
    });
  }

  flowCheckTypes() {
    return new Promise((resolve) => {
      execFile(
        require('flow-bin'), // eslint-disable-line global-require
        [this.app.path, '--show-all-errors'],
        (error, out) => {
          resolve({
            out,
{'fraction_non_alphanumeric': 0.15590484282073067, 'fraction_numerical': 0.0, 'mean_word_length': 2.393371757925072, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '7571676', 'n_tokens_mistral': 684, 'n_tokens_neox': 679, 'n_words': 152}