<commit_before>'use strict';

/* Dependencies */

// gulp and plugins
var gulp = require('gulp');
var changed = require('gulp-changed');
var cssimport = require('gulp-cssimport');
var cssmin = require('gulp-minify-css');
var flatten = require('gulp-flatten');
var gulpif = require('gulp-if');
var jshint = require('gulp-jshint');
var livereload = require('gulp-livereload');
var plumber = require('gulp-plumber');
var prefix = require('gulp-autoprefixer');
var rename = require('gulp-rename');
var rimraf = require('gulp-rimraf');
var sass = require('gulp-sass');
var size = require('gulp-size');
var streamify = require('gulp-streamify');
var uglify = require('gulp-uglify');
var gutil = require('gulp-util');

// browserify
var browserify = require('browserify');
var watchify = require('watchify');
var debowerify = require('debowerify');
var deamdify = require('deamdify');

// extras
var source = require('vinyl-source-stream');
var stylish_jshint = require('jshint-stylish');
var child_process = require('child_process');
var extend = require('extend');
var es = require('event-stream');
var yargs = require('yargs');
var path = require('path');
var fs = require('fs');

/* Directories */
var SRC = './assets';

var SCRIPTS_SRC = SRC + '/scripts';
var STYLES_SRC = SRC + '/styles';
var IMAGES_SRC = SRC + '/images';
var FONTS_SRC = SRC + '/fonts';
var VENDOR_SRC = SRC + '/vendor';

var DEST = './web/assets';

var SCRIPTS_DEST = DEST + '/scripts';
var STYLES_DEST = DEST + '/styles';
var FONTS_DEST = DEST + '/fonts';
var IMAGES_DEST = DEST + '/images';

var DEFAULT_BIND = '127.0.0.1:8080';

/* Functions */

// function for handling data for output
var write_output = function (data) {
    if (Buffer.isBuffer(data)) {
        data = data.toString();
    }

    if (typeof data === 'string') {
        data = data.trim();
    }
    gutil.log(data);
};

// function for handling errors in the bundling process
var handle_error = function (err) {
    if (err.message) {
        err = err.message;
    }

    if (typeof err === 'string') {
        err = err.trim();
    }
    write_output(gutil.colors.red(err));
};

// process a single script or script-bundle
var process_script = function (stream, prod) {
    return stream
        .pipe(plumber()) // catch errors
        .pipe(gulpif(prod, streamify(uglify())))    // minification
        .pipe(gulp.dest(SCRIPTS_DEST))  // send to target directory
        .pipe(streamify(size({showFiles: true, title: 'Scripts'})))  // display output of updated files
    ;
};

// generic function to create a browserify bundler
var create_bundler = function (entry, name, prod, opts) {
    if (opts === undefined) {
        opts = {};
    }
    opts.entries = entry;
    opts = extend({}, opts, {debug: !prod});
    var bundler = (prod ? browserify(opts) : watchify(browserify(opts)))
        .transform(debowerify)  // resolve bower paths
        .transform(deamdify)    // resolve AMD modules as CommonJS modules
    ;

    // function that gets called every time a bundle needs to be created
    var process = function () {
        return process_script(
            bundler.bundle().on('error', handle_error).pipe(source(name)),
            prod
        );
    };
    process.bundler = bundler;  // allow access to bundler
    bundler.on('update', process);
    bundler.on('error', handle_error);
    return process;<commit_msg>Gulpfile failing every javascript change fixed<commit_after>'use strict';

/* Dependencies */

// gulp and plugins
var gulp = require('gulp');
var changed = require('gulp-changed');
var cssimport = require('gulp-cssimport');
var cssmin = require('gulp-minify-css');
var flatten = require('gulp-flatten');
var gulpif = require('gulp-if');
var jshint = require('gulp-jshint');
var livereload = require('gulp-livereload');
var plumber = require('gulp-plumber');
var prefix = require('gulp-autoprefixer');
var rename = require('gulp-rename');
var rimraf = require('gulp-rimraf');
var sass = require('gulp-sass');
var size = require('gulp-size');
var streamify = require('gulp-streamify');
var uglify = require('gulp-uglify');
var gutil = require('gulp-util');

// browserify
var browserify = require('browserify');
var watchify = require('watchify');
var debowerify = require('debowerify');
var deamdify = require('deamdify');

// extras
var source = require('vinyl-source-stream');
var stylish_jshint = require('jshint-stylish');
var child_process = require('child_process');
var extend = require('extend');
var es = require('event-stream');
var yargs = require('yargs');
var path = require('path');
var fs = require('fs');

/* Directories */
var SRC = './assets';

var SCRIPTS_SRC = SRC + '/scripts';
var STYLES_SRC = SRC + '/styles';
var IMAGES_SRC = SRC + '/images';
var FONTS_SRC = SRC + '/fonts';
var VENDOR_SRC = SRC + '/vendor';

var DEST = './web/assets';

var SCRIPTS_DEST = DEST + '/scripts';
var STYLES_DEST = DEST + '/styles';
var FONTS_DEST = DEST + '/fonts';
var IMAGES_DEST = DEST + '/images';

var DEFAULT_BIND = '127.0.0.1:8080';

/* Functions */

// function for handling data for output
var write_output = function (data) {
    if (Buffer.isBuffer(data)) {
        data = data.toString();
    }

    if (typeof data === 'string') {
        data = data.trim();
    }
    gutil.log(data);
};

// function for handling errors in the bundling process
var handle_error = function (err) {
    if (err.message) {
        err = err.message;
    }

    if (typeof err === 'string') {
        err = err.trim();
    }
    write_output(gutil.colors.red(err));
};

// process a single script or script-bundle
var process_script = function (stream, prod) {
    return stream
        .pipe(plumber()) // catch errors
        .pipe(gulpif(prod, streamify(uglify())))    // minification
        .pipe(gulp.dest(SCRIPTS_DEST))  // send to target directory
        .pipe(streamify(size({showFiles: true, title: 'Scripts'})))  // display output of updated files
    ;
};

// generic function to create a browserify bundler
var create_bundler = function (entry, name, prod, opts) {
    if (opts === undefined) {
        opts = {};
    }
    opts.entries = entry;
    opts = extend({}, watchify.args, opts, {debug: !prod});
    var bundler = (prod ? browserify(opts) : watchify(browserify(opts)))
        .transform(debowerify)  // resolve bower paths
        .transform(deamdify)    // resolve AMD modules as CommonJS modules
    ;

    // function that gets called every time a bundle needs to be created
    var process = function () {
        return process_script(
            bundler.bundle().on('error', handle_error).pipe(source(name)),
            prod
        );
    };
    process.bundler = bundler;  // allow access to bundler
    bundler.on('update', process);
    bundler.on('error', handle_error);
    return process;
{'fraction_non_alphanumeric': 0.15490887713109935, 'fraction_numerical': 0.0029394473838918285, 'mean_word_length': 3.465223097112861, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '285287', 'n_tokens_mistral': 2199, 'n_tokens_neox': 2165, 'n_words': 589}