<commit_before>/**
 * @copyright 2016-present, Sitegen team
 * @flow
 */

import type {Logger} from 'debug';
import type {Compiler, Stats} from 'webpack';

import createLogger from 'debug';

export default class LogProgressPlugin {

  name: string;
  debug: Logger;
  _notifyOnCompile: boolean;

  constructor(name: string = 'webpack') {
    this.name = name;
    this.debug = createLogger(`sitegen:compile:${name}`);
    this._notifyOnCompile = true;
  }

  apply(compiler: Compiler) {
    compiler.debug = this.debug;
    compiler.plugin('compile', this._onCompile.bind(this));
    compiler.plugin('invalid', this._onInvalid.bind(this));
    compiler.plugin('done', this._onDone.bind(this));
  }

  _onDone(stats: Stats) {
    if (stats.compilation.errors.length > 0) {
      this.debug('compilation failed');
      stats.compilation.errors.forEach(error => this.debug(error.message));
    } else {
      this.debug('compilation finished');
    }
  }

  _onCompile() {
    if (this._notifyOnCompile) {
      this._notifyOnCompile = false;
      this.debug('compilation started');
    }
  }

  _onInvalid() {
    this.debug('bundled invalidated, recompiling...');
  }
}<commit_msg>chore: little adjustments to build log<commit_after>/**
 * @copyright 2016-present, Sitegen team
 * @flow
 */

import type {Logger} from 'debug';
import type {Compiler, Stats} from 'webpack';

import createLogger from 'debug';

export default class LogProgressPlugin {

  name: string;
  debug: Logger;
  _notifyOnCompile: boolean;

  constructor(name: string = 'webpack') {
    this.name = name;
    this.debug = createLogger(`sitegen:compile:${name}`);
    this._notifyOnCompile = true;
  }

  apply(compiler: Compiler) {
    compiler.debug = this.debug;
    compiler.plugin('compile', this._onCompile.bind(this));
    compiler.plugin('invalid', this._onInvalid.bind(this));
    compiler.plugin('done', this._onDone.bind(this));
  }

  _onDone(stats: Stats) {
    if (stats.compilation.errors.length > 0) {
      this.debug('compilation failed');
      stats.compilation.errors.forEach(error => {
			  if(error.details) {
          this.debug(error.details);
        }
        this.debug(error.message)
      });
    } else {
      if(stats.compilation.warnings.length > 0) {
        stats.compilation.warnings.forEach(error => this.debug(error.message));
      }

      process.stdout.write(stats.toString({colors:true}) + "\n");
      
      this.debug('compilation finished');
    }
  }

  _onCompile() {
    if (this._notifyOnCompile) {
      this._notifyOnCompile = false;
      this.debug('compilation started');
    }
  }

  _onInvalid() {
    this.debug('bundled invalidated, recompiling...');
  }
}
{'fraction_non_alphanumeric': 0.14790040876997398, 'fraction_numerical': 0.004087699739873653, 'mean_word_length': 3.3489499192245558, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '2956255', 'n_tokens_mistral': 872, 'n_tokens_neox': 828, 'n_words': 159}