<commit_before>var gulp = require('gulp');
var settings = require('./settings');
var browserify = require('browserify');
var babel = require('babelify');
var markdown = require('markdownify');
var uglify = require('gulp-uglify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var jshint = require('gulp-jshint');
var watchify = require('watchify');
var gulpif = require('gulp-if');
var Log = require('./log');

var opts = {
  debug: settings.sourcemaps,
  extensions: ['.md', '.markdown'],
  cache: {},
  packageCache: {}
};

function bundle(b) {
  var log = Log('js:build');

  return b
    .add(settings.clientEntryPoint)
    .on('file', function (file, id) {
      log.debug(file);
    })
    .bundle()
    .on('error', function (err) {
      log.error(err.toString());
      this.emit('end');
      process.exit(1);
    })
    .pipe(source('app.js'))
    .pipe(buffer())
    .pipe(gulpif(settings.minify, uglify()))
    .pipe(gulp.dest(settings.public));
}

/*
 * Define tasks
 */

module.exports = {

  lint: function () {
    return gulp.src('./lib/**/*.js')
      .pipe(jshint())
      .pipe(jshint.reporter('default'));
  },

  build: function () {
    return bundle(browserify(opts)
    .transform(babel)
    .transform(markdown));
  },

  watch: function () {
    var log = Log('watch');
    var w = watchify(browserify(opts));

    w.transform(babel)
    .transform(markdown);

    w.on('update', function (ids) {
      log.info(ids.join('\n'));
      return w.bundle();
    });

    w.on('log', function (msg) {
      log.info(msg);
    });

    return bundle(w);
  }

};<commit_msg>[build:js] Fixed watchify not rewriting app.js<commit_after>var gulp = require('gulp');
var settings = require('./settings');
var browserify = require('browserify');
var babel = require('babelify');
var markdown = require('markdownify');
var uglify = require('gulp-uglify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var jshint = require('gulp-jshint');
var watchify = require('watchify');
var gulpif = require('gulp-if');
var Log = require('./log');

var opts = {
  debug: settings.sourcemaps,
  extensions: ['.md', '.markdown'],
  cache: {},
  packageCache: {}
};

function bundle(b) {
  var log = Log('js:build');

  return b
    .add(settings.clientEntryPoint)
    .on('file', function (file, id) {
      log.debug(file);
    })
    .bundle()
    .on('error', function (err) {
      log.error(err.toString());
      this.emit('end');
      process.exit(1);
    })
    .pipe(source('app.js'))
    .pipe(buffer())
    .pipe(gulpif(settings.minify, uglify()))
    .pipe(gulp.dest(settings.public));
}

/*
 * Define tasks
 */

module.exports = {

  lint: function () {
    return gulp.src('./lib/**/*.js')
      .pipe(jshint())
      .pipe(jshint.reporter('default'));
  },

  build: function () {
    return bundle(browserify(opts)
    .transform(babel)
    .transform(markdown));
  },

  watch: function () {
    var log = Log('watch');
    var w = watchify(browserify(opts));

    w.on('update', function (ids) {
      log.info(ids.join('\n'));
      w.bundle()
      .pipe(source('app.js'))
      .pipe(buffer())
      .pipe(gulpif(settings.minify, uglify()))
      .pipe(gulp.dest(settings.public));
    });

    w.on('log', function (msg) {
      log.info(msg);
    });

    w.transform(babel)
    .transform(markdown);

    return bundle(w);
  }

};
{'fraction_non_alphanumeric': 0.20034995625546806, 'fraction_numerical': 0.0005832604257801109, 'mean_word_length': 3.1676792223572297, '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': '2681283', 'n_tokens_mistral': 1194, 'n_tokens_neox': 1157, 'n_words': 223}