<commit_before>var fs = require('fs');
var browserify = require('browserify');
var watchify = require('watchify');
var babelify = require('babelify');
var uglifyify = require('uglifyify');
var exorcist = require('exorcist');

module.exports = function bundle(o) {
  return function(err) {
    var b, w;
    var options = { debug: true };

    // Return if there was an error.
    if (err) console.error(err);

    if (o.watch) {
      options.cache = {};
      options.packageCache = {};
    }

    // Bundle the JavaScript
    b = browserify(o.entryFile, options);

    if (o.prod) {
      b.transform(babelify);
      b.transform(uglifyify);
    } else {
      b.transform(babelify, {
        sourceMap: true,
        sourceMapRelative: process.cwd(),
      });
    }

    if (o.watch) {
      w = watchify(b);

      w.bundle()
        .pipe(exorcist(o.mapFile, null, null, o.outputPath))
        .pipe(fs.createWriteStream(o.outputFile, 'utf8'));

      w.on('update', function() {
        w.bundle()
          .pipe(exorcist(o.mapFile, null, null, o.outputPath))
          .pipe(fs.createWriteStream(o.outputFile, 'utf8'));
      });

      w.on('bytes', function(bytes) {
        console.log('New bundle created with ' +  bytes + ' bytes.');
      });
    } else {
      b.bundle()
        .pipe(exorcist(o.mapFile, null, null, o.outputPath))
        .pipe(fs.createWriteStream(o.outputFile, 'utf8'));
    }
  };
};<commit_msg>change watchify output to use on.("log")<commit_after>var fs = require('fs');
var browserify = require('browserify');
var watchify = require('watchify');
var babelify = require('babelify');
var uglifyify = require('uglifyify');
var exorcist = require('exorcist');

module.exports = function bundle(o) {
  return function(err) {
    var b, w;
    var options = { debug: true };

    // Return if there was an error.
    if (err) console.error(err);

    if (o.watch) {
      options.cache = {};
      options.packageCache = {};
    }

    // Bundle the JavaScript
    b = browserify(o.entryFile, options);

    if (o.prod) {
      b.transform(babelify);
      b.transform(uglifyify);
    } else {
      b.transform(babelify, {
        sourceMap: true,
        sourceMapRelative: process.cwd(),
      });
    }

    if (o.watch) {
      w = watchify(b);

      w.bundle()
        .pipe(exorcist(o.mapFile, null, null, o.outputPath))
        .pipe(fs.createWriteStream(o.outputFile, 'utf8'));

      w.on('update', function() {
        w.bundle()
          .pipe(exorcist(o.mapFile, null, null, o.outputPath))
          .pipe(fs.createWriteStream(o.outputFile, 'utf8'));
      });

      w.on('log', function(msg) {
        console.log(msg);
      });
    } else {
      b.bundle()
        .pipe(exorcist(o.mapFile, null, null, o.outputPath))
        .pipe(fs.createWriteStream(o.outputFile, 'utf8'));
    }
  };
};
{'fraction_non_alphanumeric': 0.16449912126537786, 'fraction_numerical': 0.00210896309314587, 'mean_word_length': 2.4877450980392157, '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': '4350279', 'n_tokens_mistral': 979, 'n_tokens_neox': 945, 'n_words': 190}