<commit_before>var _ = require('lodash');
var fs = require('fs');
var async = require('async');
var gulp = require('gulp');
var gutil = require('gulp-util');
var colors = require('colors');
var plugins = require('gulp-load-plugins')();
var mkdirp = require('mkdirp');
var rimraf = require('rimraf');

var paths = {
	scripts: [
		'public/js/**/*.js',
		'app/**/*.js'
	],
	data: [
		'models/data/**/*.js'
	],
	build: 'build'
};

// Useful functions {{{
/**
* Wrapper function to quickly include an external run inside Gulp
* Can include options.ignoreFail which always triggers a success event on finish
* @param string command The command to run
* @param object options Options object
* @param function next Callback(err) to call on finish
*/
function run(command, options, next) {
	var exec = require('child_process').exec;
	gutil.log('Run: ' + command);
	exec(command, options, function(err, stdout, stderr) {
		if (stdout)
			gutil.log('Child process responded:', stdout);
		if (stderr)
			gutil.log('Child process err:', stderr);
		return next(options.ignoreFail ? null : err);
	});
}
// }}}

/**
* Generic build-all script
*/
gulp.task('build', ['scripts']);

/**
* Compile all JS files into the build directory
*/
gulp.task('scripts', [], function() {
	return gulp.src(paths.scripts)
		// .pipe(plugins.uglify())
		.pipe(plugins.concatSourcemap('all.min.js'))
		.pipe(gulp.dest(paths.build));
});

/**
* Lint all JS files
*/
gulp.task('lint', function () {
	gulp.src(paths.scripts)
		.pipe(plugins.jshint());
})

/**
* Setup the local Mongo DB with all the files located in paths.data
*/
gulp.task('db', function() {
	gulp.src(paths.data, {read: false})
		.pipe(plugins.shell('node <%=file.path%>'));
});

/**
* Output the current environment config
*/
gulp.task('config', function() {
	var config = require('./config/global');
	gutil.log(config);
});

/**
* Launch a server and watch the local file system for changes (restarting the server if any are detected)
*/
gulp.task('default', ['scripts'], function () {
	plugins.nodemon({script: 'server.js', ext: 'html js ejs'})
		.on('change', ['scripts'])
		.on('restart', function () {
			gutil.log('Restarted!'.red)
		});
});


gulp.task('bump', function(){
	gulp.src('./package.json')
		.pipe(plugins.bump({type: 'patch'})) // Types: major|minor|patch|prerelease
		.pipe(gulp.dest('./'));
});

// Debug kit {{{
gulp.task('dbtest', function(next) {
	global.config = require('./config/global');
	gutil.log('Opening DB connection...');
	require('./config/db');
	gutil.log('Testing User query...');
	var users = require('./models/users');
	users.find({}, function(err, data) {
		if (err) {
			gutil('Got error', err.red);
		} else {
			gutil.log('Got data', data);
		}<commit_msg>BUGFIX: Nodemon now ignores the build directory<commit_after>var _ = require('lodash');
var fs = require('fs');
var async = require('async');
var gulp = require('gulp');
var gutil = require('gulp-util');
var colors = require('colors');
var plugins = require('gulp-load-plugins')();
var mkdirp = require('mkdirp');
var rimraf = require('rimraf');

var paths = {
	scripts: [
		'public/js/**/*.js',
		'app/**/*.js'
	],
	data: [
		'models/data/**/*.js'
	],
	build: 'build'
};

// Useful functions {{{
/**
* Wrapper function to quickly include an external run inside Gulp
* Can include options.ignoreFail which always triggers a success event on finish
* @param string command The command to run
* @param object options Options object
* @param function next Callback(err) to call on finish
*/
function run(command, options, next) {
	var exec = require('child_process').exec;
	gutil.log('Run: ' + command);
	exec(command, options, function(err, stdout, stderr) {
		if (stdout)
			gutil.log('Child process responded:', stdout);
		if (stderr)
			gutil.log('Child process err:', stderr);
		return next(options.ignoreFail ? null : err);
	});
}
// }}}

/**
* Generic build-all script
*/
gulp.task('build', ['scripts']);

/**
* Compile all JS files into the build directory
*/
gulp.task('scripts', [], function() {
	return gulp.src(paths.scripts)
		// .pipe(plugins.uglify())
		.pipe(plugins.concatSourcemap('all.min.js'))
		.pipe(gulp.dest(paths.build));
});

/**
* Lint all JS files
*/
gulp.task('lint', function () {
	gulp.src(paths.scripts)
		.pipe(plugins.jshint());
})

/**
* Setup the local Mongo DB with all the files located in paths.data
*/
gulp.task('db', function() {
	gulp.src(paths.data, {read: false})
		.pipe(plugins.shell('node <%=file.path%>'));
});

/**
* Output the current environment config
*/
gulp.task('config', function() {
	var config = require('./config/global');
	gutil.log(config);
});

/**
* Launch a server and watch the local file system for changes (restarting the server if any are detected)
*/
gulp.task('default', ['scripts'], function () {
	plugins.nodemon({
		script: 'server.js',
		ext: 'html js ejs',
		ignore: ['build/*'],
	})
		.on('change', ['scripts'])
		.on('restart', function (a,b,c) {
			gutil.log('Restarted!'.red)
		});
});


gulp.task('bump', function(){
	gulp.src('./package.json')
		.pipe(plugins.bump({type: 'patch'})) // Types: major|minor|patch|prerelease
		.pipe(gulp.dest('./'));
});

// Debug kit {{{
gulp.task('dbtest', function(next) {
	global.config = require('./config/global');
	gutil.log('Opening DB connection...');
	require('./config/db');
	gutil.log('Testing User query...');
	var users = require('./models/users');
	users.find({}, function(err, data) {
		if (err) {
			gutil('Got error', err.red);
		} else {
			gutil.log('Got data', data);
		}
{'fraction_non_alphanumeric': 0.20209689081706436, 'fraction_numerical': 0.0, 'mean_word_length': 4.234626300851467, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6144731', 'n_tokens_mistral': 1959, 'n_tokens_neox': 1874, 'n_words': 478}