<commit_before>'use strict'

// Load global config and gulp
var config  = require(__dirname + '/tasks/config/foley.json')
var argv    = require('yargs').argv
var gulp    = require('gulp')
var plumber = require('gulp-plumber')
var debug   = require('gulp-debug')
var gulpif  = require('gulp-if')

// Load modules to run tasks from files
var requireDir   = require('require-dir')
var tasks        = requireDir(__dirname + '/tasks')
var runSequence  = require('run-sequence')

// Specific task modules
var browserSync = require('browser-sync')
var watch       = require('gulp-watch')

// Assets task. Metalsmith needs to run first
gulp.task('assets', function(callback) {
  runSequence(
    'metalsmith',
    ['svgicon', 'scss', 'webpack', 'img', 'copy', 'html'],
    callback
  )
})

// BrowserSync reload task
gulp.task('reload', function(callback) {
  browserSync.reload()
  callback()
})

// Rebuild JS task.
// We need to manually reload BrowserSync after
gulp.task('rebuildJs', function(callback) {
  runSequence(
    'webpack',
    'reload',
    callback
  )
})

// Rebuild Metalsmith task. Needed because Metalsmith doesn't do incremental builds
// We need to manually reload BrowserSync after
gulp.task('rebuildMetalsmith', function(callback) {
  runSequence(
    'assets',
    'reload',
    callback
  )
})

gulp.task('test', function(callback) {
  runSequence(
    'run-jasmine',
    callback
  )
})

// Watch task
gulp.task('watch', function(callback) {
  gulp.watch(config.paths.scss + '**/*.scss', ['scss'])
  gulp.watch(config.paths.js + '**/*.js', ['rebuildJs', 'test'])
  gulp.watch(config.paths.img + '{,**/}*.{png,jpg,gif,svg}', ['img'])
  gulp.watch(config.paths.icons + '**/*.svg', ['svgicon'])
  gulp.watch([config.paths.pages + '**/*.hbs', config.paths.partials + '**/*.hbs'], ['rebuildMetalsmith'])
  gulp.watch(config.paths.tests + '**/*.js', ['test'])
})

// Watch task - just tests
gulp.task('devWatch', function(callback) {
  gulp.watch(config.paths.js + '**/*.js', ['test'])
  gulp.watch(config.paths.tests + '**/*.js', ['test'])
})

// Build website with development assets and run server with live reloading
gulp.task('default', function(callback) {
  runSequence(
    'test',
    'clean',
    'assets',
    'browsersync',
    'watch',
    callback
  )
})

// run tests
gulp.task('dev', function(callback) {
  runSequence(
    'test',
    'devWatch',
    callback
  )
})

// Build website, either with development or minified assets depending on flag
gulp.task('deploy', function(callback) {
  runSequence(
    'test',
    'clean',
    'assets',<commit_msg>lintin<commit_after>'use strict'

// Load global config and gulp
var config  = require(__dirname + '/tasks/config/foley.json')
var argv    = require('yargs').argv
var gulp    = require('gulp')
var plumber = require('gulp-plumber')
var debug   = require('gulp-debug')
var gulpif  = require('gulp-if')

// Load modules to run tasks from files
var requireDir   = require('require-dir')
var tasks        = requireDir(__dirname + '/tasks')
var runSequence  = require('run-sequence')

// Specific task modules
var browserSync = require('browser-sync')
var watch       = require('gulp-watch')

// Assets task. Metalsmith needs to run first
gulp.task('assets', function (callback) {
  runSequence(
    'metalsmith',
    ['svgicon', 'scss', 'webpack', 'img', 'copy', 'html'],
    callback
  )
})

// BrowserSync reload task
gulp.task('reload', function (callback) {
  browserSync.reload()
  callback()
})

// Rebuild JS task.
// We need to manually reload BrowserSync after
gulp.task('rebuildJs', function (callback) {
  runSequence(
    'webpack',
    'reload',
    callback
  )
})

// Rebuild Metalsmith task. Needed because Metalsmith doesn't do incremental builds
// We need to manually reload BrowserSync after
gulp.task('rebuildMetalsmith', function (callback) {
  runSequence(
    'assets',
    'reload',
    callback
  )
})

gulp.task('test', function (callback) {
  runSequence(
    'run-jasmine',
    callback
  )
})

// Watch task
gulp.task('watch', function (callback) {
  gulp.watch(config.paths.scss + '**/*.scss', ['scss'])
  gulp.watch(config.paths.js + '**/*.js', ['rebuildJs', 'test'])
  gulp.watch(config.paths.img + '{,**/}*.{png,jpg,gif,svg}', ['img'])
  gulp.watch(config.paths.icons + '**/*.svg', ['svgicon'])
  gulp.watch([config.paths.pages + '**/*.hbs', config.paths.partials + '**/*.hbs'], ['rebuildMetalsmith'])
  gulp.watch(config.paths.tests + '**/*.js', ['test'])
})

// Watch task - just tests
gulp.task('devWatch', function (callback) {
  gulp.watch(config.paths.js + '**/*.js', ['test'])
  gulp.watch(config.paths.tests + '**/*.js', ['test'])
})

// Build website with development assets and run server with live reloading
gulp.task('default', function (callback) {
  runSequence(
    'test',
    'clean',
    'assets',
    'browsersync',
    'watch',
    callback
  )
})

// run tests
gulp.task('dev', function (callback) {
  runSequence(
    'test',
    'devWatch',
    callback
  )
})

// Build website, either with development or minified assets depending on flag
gulp.task('deploy', function (callback) {
  runSequence(
    'test',
    'clean',
    'assets',
{'fraction_non_alphanumeric': 0.17861975642760486, 'fraction_numerical': 0.0, 'mean_word_length': 3.7251141552511418, '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': '2833945', 'n_tokens_mistral': 1746, 'n_tokens_neox': 1715, 'n_words': 415}