<commit_before>var del = require('del'),
	gulp = require('gulp'),
	gutil = require('gulp-util'),
	less = require('gulp-less'),
	deploy = require("gulp-gh-pages"),
	browserify = require('browserify'),
	watchify = require('watchify'),
	reactify = require('reactify'),
	source = require('vinyl-source-stream'),
	merge = require('merge-stream'),
	chalk = require('chalk');

/**
 * Clean Everything
 */

gulp.task('clean', function(done) {
	del(['./examples/public/build'], done);
});

/**
 * Build Default theme from LESS
 */

gulp.task('less', function() {
	return gulp.src('less/default.less')
		.pipe(less())
		.pipe(gulp.dest('dist'));
});


/**
 * Build Examples
 */

function doBundle(target, name, dest) {
	return target.bundle()
		.on('error', function(e) {
			gutil.log('Browserify Error', e);
		})
		.pipe(source(name))
		.pipe(gulp.dest(dest));
}

function watchBundle(target, name, dest) {
	return watchify(target)
		.on('update', function (scriptIds) {
			scriptIds = scriptIds
			.filter(function(i) { return i.substr(0,2) !== './' })
				.map(function(i) { return chalk.blue(i.replace(__dirname, '')) });
			if (scriptIds.length > 1) {
				gutil.log(scriptIds.length + ' Scripts updated:\n* ' + scriptIds.join('\n* ') + '\nrebuilding...');
			} else {
				gutil.log(scriptIds[0] + ' updated, rebuilding...');
			}
			doBundle(target, name, dest);
		})
		.on('time', function (time) {
			gutil.log(chalk.green(name + ' built in ' + (Math.round(time / 10) / 100) + 's'));
		});
}

function buildExamples(watch) {
	
	var opts = watch ? watchify.args : {};
	
	opts.debug = true;
	opts.hasExports = true;
	
	var dest = './examples/public/build';
	
	var common = browserify(opts)
		.require('react')
		.require('underscore');
	
	var select = browserify(opts)
		.exclude('react')
		.exclude('underscore')
		.require('./lib/Select.js', { expose: 'react-select' });

	var app = browserify(opts)
		.add('./examples/src/app.js')
		.exclude('react')
		.exclude('react-select')
		.transform(reactify);
	
	/*
	var standalone = browserify(opts)
		.exclude('react')
		.exclude('underscore')
		.add('./lib/Select.js', { expose: 'react-select' })
		.transform(reactify)
		.transform(shim)
	*/
	
	if (watch) {
		watchBundle(app, 'app-bundle.js', dest);
		watchBundle(select, 'select-bundle.js', dest);
		// watchBundle(standalone, 'select-standalone.js', dest);
	}
	
	return merge(
		doBundle(common, 'global-bundle.js', dest),
		doBundle(select, 'select-bundle.js', dest),
		doBundle(app, 'app-bundle.js', dest)
		// doBundle(standalone, 'select-standalone.js', dest),
	);
	
}

gulp.task('build-example-css', function() {
	return gulp.src('examples/src/example.less')
		.pipe(less())
		.pipe(gulp.dest('./examples/public/build'));
});

gulp.task('build-examples', function() {
	return buildExamples();<commit_msg>gulp build-examples should build css too<commit_after>var del = require('del'),
	gulp = require('gulp'),
	gutil = require('gulp-util'),
	less = require('gulp-less'),
	deploy = require("gulp-gh-pages"),
	browserify = require('browserify'),
	watchify = require('watchify'),
	reactify = require('reactify'),
	source = require('vinyl-source-stream'),
	merge = require('merge-stream'),
	chalk = require('chalk');

/**
 * Clean Everything
 */

gulp.task('clean', function(done) {
	del(['./examples/public/build'], done);
});

/**
 * Build Default theme from LESS
 */

gulp.task('less', function() {
	return gulp.src('less/default.less')
		.pipe(less())
		.pipe(gulp.dest('dist'));
});


/**
 * Build Examples
 */

function doBundle(target, name, dest) {
	return target.bundle()
		.on('error', function(e) {
			gutil.log('Browserify Error', e);
		})
		.pipe(source(name))
		.pipe(gulp.dest(dest));
}

function watchBundle(target, name, dest) {
	return watchify(target)
		.on('update', function (scriptIds) {
			scriptIds = scriptIds
			.filter(function(i) { return i.substr(0,2) !== './' })
				.map(function(i) { return chalk.blue(i.replace(__dirname, '')) });
			if (scriptIds.length > 1) {
				gutil.log(scriptIds.length + ' Scripts updated:\n* ' + scriptIds.join('\n* ') + '\nrebuilding...');
			} else {
				gutil.log(scriptIds[0] + ' updated, rebuilding...');
			}
			doBundle(target, name, dest);
		})
		.on('time', function (time) {
			gutil.log(chalk.green(name + ' built in ' + (Math.round(time / 10) / 100) + 's'));
		});
}

function buildExamples(watch) {
	
	var opts = watch ? watchify.args : {};
	
	opts.debug = true;
	opts.hasExports = true;
	
	var dest = './examples/public/build';
	
	var common = browserify(opts)
		.require('react')
		.require('underscore');
	
	var select = browserify(opts)
		.exclude('react')
		.exclude('underscore')
		.require('./lib/Select.js', { expose: 'react-select' });

	var app = browserify(opts)
		.add('./examples/src/app.js')
		.exclude('react')
		.exclude('react-select')
		.transform(reactify);
	
	/*
	var standalone = browserify(opts)
		.exclude('react')
		.exclude('underscore')
		.add('./lib/Select.js', { expose: 'react-select' })
		.transform(reactify)
		.transform(shim)
	*/
	
	if (watch) {
		watchBundle(app, 'app-bundle.js', dest);
		watchBundle(select, 'select-bundle.js', dest);
		// watchBundle(standalone, 'select-standalone.js', dest);
	}
	
	return merge(
		doBundle(common, 'global-bundle.js', dest),
		doBundle(select, 'select-bundle.js', dest),
		doBundle(app, 'app-bundle.js', dest)
		// doBundle(standalone, 'select-standalone.js', dest),
	);
	
}

gulp.task('build-example-css', function() {
	return gulp.src('examples/src/example.less')
		.pipe(less())
		.pipe(gulp.dest('./examples/public/build'));
});

gulp.task('build-examples', ['build-example-css'], function() {
	return buildExamples();
{'fraction_non_alphanumeric': 0.2080536912751678, 'fraction_numerical': 0.0031790886612504416, 'mean_word_length': 3.9850352112676055, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '703282', 'n_tokens_mistral': 2191, 'n_tokens_neox': 1981, 'n_words': 355}