<commit_before>var gulp = require("gulp");
var gutil = require("gulp-util");
var glob = require("glob");
var tap = require("gulp-tap");
var concat = require("gulp-concat");
var path = require("path");
var fs = require("fs");
var amdOptimize = require("amd-optimize");
var replace = require("gulp-replace");
var indent = require("gulp-indent");
var insert = require("gulp-insert");
var del = require("del");
var uglify = require("gulp-uglify");
var rename = require("gulp-rename");
var sass = require("gulp-ruby-sass");
var prefix = require("gulp-autoprefixer");
var openFile = require("gulp-open");
var argv = require("yargs")
			.alias("f", "file")
			.alias("s", "signal")
			.alias("i", "instrument")
			.alias("o", "source")
			.alias("v", "event")
			.alias("t", "control")
			.alias("e", "effect")
			.alias("c", "core")
			.alias("m", "component")
			.alias("y", "type")
			.argv;
var webserver = require("gulp-webserver");
var KarmaServer = require("karma").Server;

/**
 *  BUILDING
 */

//collect all of the files into one file prefixed with 'require'
gulp.task("collectDependencies", function(done) {
	glob("../Tone/*/*.js", function(err, files){
		var modules = [];
		gutil.log(gutil.colors.magenta("files found:", files.length));
		files.forEach(function(file){
			//remove the precedding ../ and the trailing .js
			var module = file.substring(3, file.length - 3);
			modules.push(module);
		});
		//write it to disk
		var reqString = "/* BEGIN REQUIRE */ require("+JSON.stringify(modules)+", function(){});";
		fs.writeFile("toneMain.js", reqString, done);
	});
});

gulp.task("compile", ["collectDependencies"], function(done){
	gulp.src("./toneMain.js")
		// Traces all modules and outputs them in the correct order.
		.pipe(amdOptimize("gulp/toneMain", {
			baseUrl : "../",
			preserveComments : true
		}))
		.pipe(concat("Tone.js"))
		.pipe(replace("'use strict';", ""))
		//indent the contents
		.pipe(indent({
			tabs:true,
			amount:1
		}))
		//replace the MainModule
		.pipe(replace(/\/\* BEGIN REQUIRE \*\/(.|\n)*/gm, ""))
		.pipe(replace("define('Tone/core/Tone', [], ", "Main("))
		//replace the ToneModules
		.pipe(replace(/define\(\s*'([^']*)'\s*\,\s*\[\s*'([^']*'\s*\,*\s*)+?\]\s*\,\s*/g, "Module("))
		.pipe(insert.prepend(fs.readFileSync("./fragments/before.frag").toString()))
		.pipe(gulp.dest("../build/"))
		.pipe(concat("p5.Tone.js"))
		.pipe(gulp.dest("../build/"))
		.on("end", done);
});

gulp.task("footer", ["compile"], function(done){
	gulp.src("../build/Tone.js")
		.pipe(insert.append(fs.readFileSync("./fragments/after.frag").toString()))
		.pipe(gulp.dest("../build/"))
		.on("end", done);
});

gulp.task("p5Footer", ["compile"], function(done){
	gulp.src("../build/p5.Tone.js")
		.pipe(insert.append(fs.readFileSync("./fragments/p5-after.frag").toString()))
		.pipe(gulp.dest("../build/"))
		.on("end", done);
});

gulp.task("build", ["footer", "p5Footer"], function(){
	gulp.src("../build/{p5.Tone,Tone}.js")
		.pipe(uglify({
				preserveComments : "some",
				compress: {
					dead_code : true,
					evaluate : true,
					loops : true,
					if_return : true,
					hoist_vars : true,
					booleans : true,
					conditionals : true,
					sequences : true,
					comparisons : true,
					hoist_funs : true,
					join_vars : true,
					cascade : true,
				},
			}))
		.pipe(rename({
			suffix : ".min"
		}))
		// .pipe(del(["./toneMain.js"]))
		.pipe(gulp.dest("../build/"));
});

gulp.task("cleanup", ["build"], function(){<commit_msg>don't minify p5.Tone<commit_after>var gulp = require("gulp");
var gutil = require("gulp-util");
var glob = require("glob");
var tap = require("gulp-tap");
var concat = require("gulp-concat");
var path = require("path");
var fs = require("fs");
var amdOptimize = require("amd-optimize");
var replace = require("gulp-replace");
var indent = require("gulp-indent");
var insert = require("gulp-insert");
var del = require("del");
var uglify = require("gulp-uglify");
var rename = require("gulp-rename");
var sass = require("gulp-ruby-sass");
var prefix = require("gulp-autoprefixer");
var openFile = require("gulp-open");
var argv = require("yargs")
			.alias("f", "file")
			.alias("s", "signal")
			.alias("i", "instrument")
			.alias("o", "source")
			.alias("v", "event")
			.alias("t", "control")
			.alias("e", "effect")
			.alias("c", "core")
			.alias("m", "component")
			.alias("y", "type")
			.argv;
var webserver = require("gulp-webserver");
var KarmaServer = require("karma").Server;

/**
 *  BUILDING
 */

//collect all of the files into one file prefixed with 'require'
gulp.task("collectDependencies", function(done) {
	glob("../Tone/*/*.js", function(err, files){
		var modules = [];
		gutil.log(gutil.colors.magenta("files found:", files.length));
		files.forEach(function(file){
			//remove the precedding ../ and the trailing .js
			var module = file.substring(3, file.length - 3);
			modules.push(module);
		});
		//write it to disk
		var reqString = "/* BEGIN REQUIRE */ require("+JSON.stringify(modules)+", function(){});";
		fs.writeFile("toneMain.js", reqString, done);
	});
});

gulp.task("compile", ["collectDependencies"], function(done){
	gulp.src("./toneMain.js")
		// Traces all modules and outputs them in the correct order.
		.pipe(amdOptimize("gulp/toneMain", {
			baseUrl : "../",
			preserveComments : true
		}))
		.pipe(concat("Tone.js"))
		.pipe(replace("'use strict';", ""))
		//indent the contents
		.pipe(indent({
			tabs:true,
			amount:1
		}))
		//replace the MainModule
		.pipe(replace(/\/\* BEGIN REQUIRE \*\/(.|\n)*/gm, ""))
		.pipe(replace("define('Tone/core/Tone', [], ", "Main("))
		//replace the ToneModules
		.pipe(replace(/define\(\s*'([^']*)'\s*\,\s*\[\s*'([^']*'\s*\,*\s*)+?\]\s*\,\s*/g, "Module("))
		.pipe(insert.prepend(fs.readFileSync("./fragments/before.frag").toString()))
		.pipe(gulp.dest("../build/"))
		.pipe(concat("p5.Tone.js"))
		.pipe(gulp.dest("../build/"))
		.on("end", done);
});

gulp.task("footer", ["compile"], function(done){
	gulp.src("../build/Tone.js")
		.pipe(insert.append(fs.readFileSync("./fragments/after.frag").toString()))
		.pipe(gulp.dest("../build/"))
		.on("end", done);
});

gulp.task("p5Footer", ["compile"], function(done){
	gulp.src("../build/p5.Tone.js")
		.pipe(insert.append(fs.readFileSync("./fragments/p5-after.frag").toString()))
		.pipe(gulp.dest("../build/"))
		.on("end", done);
});

gulp.task("build", ["footer", "p5Footer"], function(){
	gulp.src("../build/Tone.js")
		.pipe(uglify({
				preserveComments : "some",
				compress: {
					dead_code : true,
					evaluate : true,
					loops : true,
					if_return : true,
					hoist_vars : true,
					booleans : true,
					conditionals : true,
					sequences : true,
					comparisons : true,
					hoist_funs : true,
					join_vars : true,
					cascade : true,
				},
			}))
		.pipe(rename({
			suffix : ".min"
		}))
		// .pipe(del(["./toneMain.js"]))
		.pipe(gulp.dest("../build/"));
});

gulp.task("cleanup", ["build"], function(){
{'fraction_non_alphanumeric': 0.23882741773243282, 'fraction_numerical': 0.0025865785313981893, 'mean_word_length': 3.7638603696098563, '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': '2798769', 'n_tokens_mistral': 2830, 'n_tokens_neox': 2524, 'n_words': 469}