<commit_before>'use strict';

var webpack = require('webpack');
var EventEmitter = require('events').EventEmitter;
var util = require('util');
var _ = require('lodash');

var WebpackCompiler = function(webpackConfig) {
  EventEmitter.call(this);
  this._config = webpackConfig;
};

util.inherits(WebpackCompiler, EventEmitter);

WebpackCompiler.prototype = _.extend(WebpackCompiler.prototype, {

  addProductionPlugins: function() {
    this._config.plugins.push(new webpack.optimize.DedupePlugin());
    var uglifyJsOptions = {
      minimize: true,
      mangle: false
    };
    this._config.plugins.push(new webpack.optimize.UglifyJsPlugin(uglifyJsOptions));
  },


  buildOnce: function() {
    this._compiler().run(this._afterBuild.bind(this));
  },


  buildContinuously: function() {
    this._compiler().watch({ aggregateTimeout: 300, poll: true }, this._afterBuild.bind(this));
  },


  _afterBuild: function(err, stats) {
    if (err) return this.emit('error', [err]);
    stats = stats.toJson();
    if (stats.errors.length > 0) return this.emit('error', stats.errors);
    this.emit('success', stats);
  },


  _compiler: function() {
    return webpack(this._config);
  }


});





module.exports = WebpackCompiler;<commit_msg>feat(webpack compiler): add possibility to override watch config<commit_after>'use strict';

var webpack = require('webpack');
var EventEmitter = require('events').EventEmitter;
var util = require('util');
var _ = require('lodash');

var WebpackCompiler = function(webpackConfig) {
  EventEmitter.call(this);
  this._config = webpackConfig;
};

util.inherits(WebpackCompiler, EventEmitter);

WebpackCompiler.prototype = _.extend(WebpackCompiler.prototype, {

  addProductionPlugins: function() {
    this._config.plugins.push(new webpack.optimize.DedupePlugin());
    var uglifyJsOptions = {
      minimize: true,
      mangle: false
    };
    this._config.plugins.push(new webpack.optimize.UglifyJsPlugin(uglifyJsOptions));
  },


  buildOnce: function() {
    this._compiler().run(this._afterBuild.bind(this));
  },


  buildContinuously: function() {
    var watchOptions = Object.assign({ aggregateTimeout: 300, poll: true }, this._config.watchOptions || {});
    this._compiler().watch(watchOptions, this._afterBuild.bind(this));
  },


  _afterBuild: function(err, stats) {
    if (err) return this.emit('error', [err]);
    stats = stats.toJson();
    if (stats.errors.length > 0) return this.emit('error', stats.errors);
    this.emit('success', stats);
  },


  _compiler: function() {
    return webpack(this._config);
  }


});





module.exports = WebpackCompiler;
{'fraction_non_alphanumeric': 0.1484732824427481, 'fraction_numerical': 0.0030534351145038168, 'mean_word_length': 4.393004115226337, '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': '6503819', 'n_tokens_mistral': 833, 'n_tokens_neox': 799, 'n_words': 150}