<commit_before>import gulp from 'gulp';
import babel from 'gulp-babel';
import concat from 'gulp-concat';
import eslint from 'gulp-eslint';
import sourcemaps from 'gulp-sourcemaps';
import browserSync from 'browser-sync';
import cp from 'child_process';

const JS_PATH = './_js';

let jekyll   = process.platform === 'win32' ? 'jekyll.bat' : 'jekyll';
let messages = {
    jekyllBuild: '<span style="color: grey">Running:</span> $ jekyll build'
};

gulp.task('lint', () => {
  return gulp.src([JS_PATH + '/**/*.js', '!' + JS_PATH + '/libs/**'])
    .pipe(eslint())
    .pipe(eslint.format())
    .pipe(eslint.failAfterError());
});

gulp.task('babel', () => {
  return gulp.src([JS_PATH + '/libs/*.js', JS_PATH + '/*.js'])
    .pipe(sourcemaps.init())
    .pipe(babel({
      presets: ['es2015'],
      ignore: [
          JS_PATH + '/libs/*'
      ]
    }))
    .pipe(concat('scripts.js'))
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('./js'));
});


gulp.task('jekyll-build', function (done) {
  browserSync.notify(messages.jekyllBuild);
  return cp.spawn( jekyll , ['build', '--config', '_config.yml,_config_dev.yml'], {stdio: 'inherit'})
    .on('close', done);
});

gulp.task('jekyll-rebuild', ['jekyll-build'], function () {
  browserSync.reload();
});

gulp.task('browser-sync', ['babel', 'jekyll-build'], function() {
  browserSync({
    server: {
      baseDir: '_site'
    }
  });
});

gulp.task('watch', function () {
  gulp.watch(JS_PATH + '/**/*.js', ['lint']);
  gulp.watch(JS_PATH + '/**/*.js', ['babel']);
  gulp.watch(['*.html', '_layouts/*.html', '_contents/*'], ['jekyll-rebuild']);
});

gulp.task('default', ['browser-sync', 'watch']);
<commit_msg>ADD: browserify tasks and dependencies<commit_after>import gulp from 'gulp';
import babel from 'gulp-babel';
import concat from 'gulp-concat';
import eslint from 'gulp-eslint';
import sourcemaps from 'gulp-sourcemaps';
import browserSync from 'browser-sync';
import cp from 'child_process';


import browserify from 'browserify';
import watchify from 'watchify';
import babelify from 'babelify';
import source from 'vinyl-source-stream';
import buffer from 'vinyl-buffer';
import merge from 'utils-merge';
import rename from 'gulp-rename';
import uglify from 'gulp-uglify';
import gutil from 'gulp-util';
import chalk from 'chalk';

const JS_PATH = './_js';

let jekyll   = process.platform === 'win32' ? 'jekyll.bat' : 'jekyll';
let messages = {
    jekyllBuild: '<span style="color: grey">Running:</span> $ jekyll build'
};

gulp.task('lint', () => {
  return gulp.src([JS_PATH + '/**/*.js', '!' + JS_PATH + '/libs/**'])
    .pipe(eslint())
    .pipe(eslint.format())
    .pipe(eslint.failAfterError());
});

gulp.task('babel', () => {
  return gulp.src([JS_PATH + '/libs/*.js', JS_PATH + '/*.js'])
    .pipe(sourcemaps.init())
    .pipe(babel({
      presets: ['es2015'],
      ignore: [
          JS_PATH + '/libs/*'
      ]
    }))
    .pipe(concat('scripts.js'))
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('./js'));
});

gulp.task('concat', () => {
  return gulp.src([JS_PATH + '/libs/*.js', 'js/*.min.js'])
    .pipe(sourcemaps.init())
    .pipe(concat('scripts.js'))
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('./js'));
});

gulp.task('watchify', function () {
  let args = merge(watchify.args, { debug: true })
  let bundler = watchify(browserify(JS_PATH + '/main.js', args)).transform(babelify, { /* opts */ })
  bundle_js(bundler)

  bundler.on('update', function () {
    bundle_js(bundler)
  })
})

/* nicer browserify errors */
function map_error(err) {
  if (err.fileName) {
    // regular error
    gutil.log(chalk.red(err.name)
      + ': '
      + chalk.yellow(err.fileName.replace(__dirname + JS_PATH, ''))
      + ': '
      + 'Line '
      + chalk.magenta(err.lineNumber)
      + ' & '
      + 'Column '
      + chalk.magenta(err.columnNumber || err.column)
      + ': '
      + chalk.blue(err.description))
  } else {
    // browserify error..
    gutil.log(chalk.red(err.name)
      + ': '
      + chalk.yellow(err.message))
  }

  this.end()
}

function bundle_js(bundler) {
  return bundler.bundle()
    .on('error', map_error)
    .pipe(source('scripts.js'))
    .pipe(buffer())
    .pipe(gulp.dest('js/'))
    .pipe(rename('scripts.min.js'))
    .pipe(sourcemaps.init({ loadMaps: true }))
      // capture sourcemaps from transforms
     .pipe(uglify())
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('js'))
}

gulp.task('jekyll-build', function (done) {
  browserSync.notify(messages.jekyllBuild);
  return cp.spawn( jekyll , ['build', '--config', '_config.yml,_config_dev.yml'], {stdio: 'inherit'})
    .on('close', done);
});

gulp.task('jekyll-rebuild', ['jekyll-build'], function () {
  browserSync.reload();
});

gulp.task('browser-sync', ['jekyll-build'], function() {
  browserSync({
    server: {
      baseDir: '_site'
    }
  });
});

gulp.task('watch', function () {
  gulp.watch(JS_PATH + '/**/*.js', ['lint', 'watchify']);
  gulp.watch(['*.html', '_layouts/*.html', '_contents/*'], ['jekyll-rebuild']);
});

gulp.task('default', ['watchify', 'browser-sync', 'watch']);

{'fraction_non_alphanumeric': 0.22065727699530516, 'fraction_numerical': 0.002347417840375587, 'mean_word_length': 3.528786536758193, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 12, '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': '718946', 'n_tokens_mistral': 1873, 'n_tokens_neox': 1822, 'n_words': 334}