<commit_before>import browserSync from 'browser-sync';
import gulpLoadPlugins from 'gulp-load-plugins';
import runSequence from 'run-sequence';

import * as paths from './paths';
import gulp from './_gulp';


const $ = gulpLoadPlugins();

const BS_OPTIONS = {
  ghostMode: false,
  open: false,
  notify: false,
  port: 9000
};

const BS_SERVER_OPTIONS = {
    baseDir: ['.', paths.SRC_DIR, paths.TMP_DIR],
    middleware: (req, res, next) => {
      res.setHeader('Access-Control-Allow-Origin', '*');
      next();
    }
};


function reportChange(event) {
  $.util.log(
    `File ${event.path} was ${event.type}, running tasks…`
  );
}


gulp.task('reload', () => browserSync.reload());


gulp.task('reload:build', (callback) => {
  return runSequence('build', 'reload', callback);
});


gulp.task('reload:dist', (callback) => {
  return runSequence('dist', 'reload', callback);
});


gulp.task('serve:dev', ['compile:styles', 'js:lint'], (done) => {
  const opts = Object.assign({}, BS_OPTIONS, {server: BS_SERVER_OPTIONS});
  browserSync(opts, done);

  gulp.watch(paths.SRC_SCRIPT, ['js:lint', 'reload'])
  .on('change', reportChange);
  gulp.watch(paths.SRC_INDEX, ['reload']).on('change', reportChange);
  gulp.watch(paths.SRC_STYLE, ['compile:styles', 'reload'])
  .on('change', reportChange);
});


gulp.task('serve:build', ['build'], (done) => {
  let serverOpts = Object.assign(
    {}, BS_SERVER_OPTIONS, {baseDir: [paths.BUILD_DIR]}
  );
  let opts = Object.assign({}, BS_OPTIONS, {server: serverOpts});
  browserSync(opts, done);

  gulp.watch(paths.SRC_ALL, ['reload:build']).on('change', reportChange);
});


gulp.task('serve:dist', ['dist'], (done) => {
  let serverOpts = Object.assign(
    {}, BS_SERVER_OPTIONS, {baseDir: [paths.DIST_DIR]}
  );
  let opts = Object.assign({}, BS_OPTIONS, {server: serverOpts});
  browserSync(opts, done);

  gulp.watch(paths.SRC_ALL, ['reload:dist']).on('change', reportChange);
});<commit_msg>Refactor our alternate serves<commit_after>import browserSync from 'browser-sync';
import gulpLoadPlugins from 'gulp-load-plugins';
import runSequence from 'run-sequence';

import * as paths from './paths';
import gulp from './_gulp';


const $ = gulpLoadPlugins();

const BS_OPTIONS = {
  ghostMode: false,
  open: false,
  notify: false,
  port: 9000
};

const BS_SERVER_OPTIONS = {
    baseDir: ['.', paths.SRC_DIR, paths.TMP_DIR],
    middleware: (req, res, next) => {
      res.setHeader('Access-Control-Allow-Origin', '*');
      next();
    }
};


function reportChange(event) {
  $.util.log(
    `File ${event.path} was ${event.type}, running tasks…`
  );
}


function _serve(baseDir, reloadTasks, done) {
  const serverOpts = Object.assign(
    {}, BS_SERVER_OPTIONS, {baseDir: baseDir}
  );
  const opts = Object.assign({}, BS_OPTIONS, {server: serverOpts});
  browserSync(opts, done);

  return gulp.watch(paths.SRC_ALL, reloadTasks).on('change', reportChange);
}


gulp.task('reload', () => browserSync.reload());


gulp.task('reload:build', (callback) => {
  return runSequence('build', 'reload', callback);
});


gulp.task('reload:dist', (callback) => {
  return runSequence('dist', 'reload', callback);
});


gulp.task('serve:dev', ['compile:styles', 'js:lint'], (done) => {
  const opts = Object.assign({}, BS_OPTIONS, {server: BS_SERVER_OPTIONS});
  browserSync(opts, done);

  gulp.watch(paths.SRC_SCRIPT, ['js:lint', 'reload'])
  .on('change', reportChange);
  gulp.watch(paths.SRC_INDEX, ['reload']).on('change', reportChange);
  gulp.watch(paths.SRC_STYLE, ['compile:styles', 'reload'])
  .on('change', reportChange);
});


gulp.task('serve:build', ['build'], (done) => {
  return _serve([paths.BUILD_DIR], ['reload:build'], done);
});


gulp.task('serve:dist', ['dist'], (done) => {
  return _serve([paths.DIST_DIR], ['reload:dist'], done);
});
{'fraction_non_alphanumeric': 0.2008916863362182, 'fraction_numerical': 0.002098085496984002, 'mean_word_length': 4.922360248447205, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '5646724', 'n_tokens_mistral': 1344, 'n_tokens_neox': 1315, 'n_words': 263}