<commit_before>// -- SETUP --------------------------------------------------------------------

var gulp = require("gulp");
var sourcemaps = require("gulp-sourcemaps");
var liveReload = require("gulp-livereload");
var uglify = require("gulp-uglify");
var newer = require("gulp-newer");
var ghPages = require("gulp-gh-pages");
var open = require("gulp-open");
var gutil = require("gulp-util");
var jshint = require("gulp-jshint"); // Requires npm jshint
var stylish = require("jshint-stylish");
var browserify = require("browserify");
var source = require("vinyl-source-stream");
var buffer = require("vinyl-buffer");
var del = require("del");
var express = require("express");
var path = require("path");
var fs = require("fs");
var runSequence = require("run-sequence");
var gulpif = require("gulp-if");
var rename = require("gulp-rename");

// Check the command line to see if this is a production build
var isProduction = (gutil.env.p || gutil.env.production);
console.log("Build environment: " + (isProduction ? "production" : "debug"));


// -- PATHS --------------------------------------------------------------------

var mainFilename = "bbox-aligned-text.js";
var paths = {
    examples: "examples/",
    jsLib: ["lib/**/*.js"],
    jsEntry: ["lib/" + mainFilename],
    dest: "dist"
};


// -- BUILD TASKS --------------------------------------------------------------
// These gulp tasks take everything that is in src/, process them and output
// them into lib/.

// Combine, sourcemap and uglify JS libraries into main.js. This uses browserify
// (CommonJS-style modules).
gulp.task("js-browserify", function() {
    var b = browserify({
        entries: paths.jsEntry,
        debug: true
    })
    return b.bundle()
        .on("error", gutil.log)
        .pipe(source(mainFilename))
        .pipe(buffer())
        .pipe(gulp.dest(paths.dest))
        .pipe(sourcemaps.init({ loadMaps: true }))
            .pipe(uglify())
            .on("error", gutil.log)
        .pipe(sourcemaps.write())
        .pipe(rename({ extname: ".min.js" }))
        .pipe(gulp.dest(paths.dest))
        .pipe(liveReload());<commit_msg>Update gulp to build out the module in a universal way<commit_after>// -- SETUP --------------------------------------------------------------------

var gulp = require("gulp");
var sourcemaps = require("gulp-sourcemaps");
var liveReload = require("gulp-livereload");
var uglify = require("gulp-uglify");
var newer = require("gulp-newer");
var ghPages = require("gulp-gh-pages");
var open = require("gulp-open");
var gutil = require("gulp-util");
var jshint = require("gulp-jshint"); // Requires npm jshint
var stylish = require("jshint-stylish");
var browserify = require("browserify");
var source = require("vinyl-source-stream");
var buffer = require("vinyl-buffer");
var del = require("del");
var express = require("express");
var path = require("path");
var fs = require("fs");
var runSequence = require("run-sequence");
var gulpif = require("gulp-if");
var rename = require("gulp-rename");

// Check the command line to see if this is a production build
var isProduction = (gutil.env.p || gutil.env.production);
console.log("Build environment: " + (isProduction ? "production" : "debug"));


// -- PATHS --------------------------------------------------------------------

var globalName = "BboxAlignedText";
var mainFilename = "bbox-aligned-text.js";
var paths = {
    examples: "examples/",
    jsLib: ["lib/**/*.js"],
    jsEntry: ["lib/" + mainFilename],
    dest: "dist"
};


// -- BUILD TASKS --------------------------------------------------------------
// These gulp tasks take everything that is in src/, process them and output
// them into lib/.

// Combine, sourcemap and uglify JS libraries into main.js. This uses browserify
// (CommonJS-style modules).
gulp.task("js-browserify", function() {
    var b = browserify({
        entries: paths.jsEntry,
        debug: true,
        // Build module in a universal way, so that it can be loaded with
        // CommonJS or can be loaded to a global variable
        standalone: globalName 
    })
    return b.bundle()
        .on("error", gutil.log)
        .pipe(source(mainFilename))
        .pipe(buffer())
        .pipe(gulp.dest(paths.dest))
        .pipe(sourcemaps.init({ loadMaps: true }))
            .pipe(uglify())
            .on("error", gutil.log)
        .pipe(sourcemaps.write())
        .pipe(rename({ extname: ".min.js" }))
        .pipe(gulp.dest(paths.dest))
        .pipe(liveReload());
{'fraction_non_alphanumeric': 0.23924611973392462, 'fraction_numerical': 0.0, 'mean_word_length': 2.3414814814814813, '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': '2788834', 'n_tokens_mistral': 1321, 'n_tokens_neox': 1297, 'n_words': 356}