<commit_before>module.exports = function(grunt) {

	grunt.initConfig({

		pkg: grunt.file.readJSON('package.json'),

		jsdoc : {
			multi : {
				src: ['multi/**/*.js', 'README.md'], 
				options: {
					destination: './documentation/'
				}
			}
		},

		jshint: {
			files: ['Gruntfile.js', 'app.js', 'package.json', 'multi/**/*.js', 'tests/**/*.js'],
			options: {
				// ignore third party libs
				ignores: ['node_modules', 'documentation', 'multi/debs/*', 'tests/client/lib/*.js'],
				// options here to override JSHint defaults
				globals: {
					jQuery: true,
					console: true,
					module: true,
					document: true
				}
			}
		},

		/* 
		* builds the client side multi lib into one file 
		* see https://github.com/gruntjs/grunt-contrib-requirejs
		*/
		requirejs: {
			client: {
				options: {
					baseUrl: 'multi/client',
					out: 'public/js/lib/multi.js',
					name: 'index',
					wrap: {
						end: 'define(["index"], function(index) { return index; });'
					},
					optimize: 'none'
				}
			}
		},

		// client side testing
		qunit: {
			files: ['tests/client/**/*.html']
		},

		watch: {
			// test js files on file change
			all: {
				files: ['<%= jshint.files %>'],
				tasks: ['jshint']
			},
			// build and test client lib on file change
			client: {
				files: ['multi/client/**/*.js', 'multi/shared/**/*.js'],
				tasks: ['requirejs:client', 'qunit', 'qunitShared']
			},
			// test server lib on file change
			server: {
				files: ['multi/server/**/*.js', 'multi/shared/**/*.js'],
				tasks: ['qunitServer', 'qunitShared']
			},
			// test server on test change
			testsServer: {
				files: ['tests/server/**/*.js'],
				tasks: ['qunitServer']
			},
			// test shared on test change
			testsShared: {
				files: ['tests/shared/**/*.js'],
				tasks: ['qunitShared']
			},
			// test client on test change
			testsClient: {
				files: ['tests/client/**/*.js'],
				tasks: ['qunit']
			}
		}
	});

	grunt.loadNpmTasks('grunt-jsdoc');
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-qunit');
	grunt.loadNpmTasks('grunt-contrib-watch');
	grunt.loadNpmTasks('grunt-contrib-requirejs');

	function filterQunitResult(error, result, code) {
		if (error) {
			grunt.log.error(error);
		} else {
			if (result.toString().indexOf("Error") !== -1) {
				grunt.log.write(result + '\n');
				throw 'Something above threw an error \u2191';<commit_msg>Only jshint changed files, not all.<commit_after>module.exports = function(grunt) {

	grunt.initConfig({

		pkg: grunt.file.readJSON('package.json'),

		jsdoc : {
			multi : {
				src: ['multi/**/*.js', 'README.md'], 
				options: {
					destination: './documentation/'
				}
			}
		},

		jshint: {
			files: ['Gruntfile.js', 'app.js', 'package.json', 'multi/**/*.js', 'tests/**/*.js'],
			options: {
				// ignore third party libs
				ignores: ['node_modules', 'documentation', 'multi/debs/*', 'tests/client/lib/*.js'],
				// options here to override JSHint defaults
				globals: {
					jQuery: true,
					console: true,
					module: true,
					document: true
				}
			}
		},

		/* 
		* builds the client side multi lib into one file 
		* see https://github.com/gruntjs/grunt-contrib-requirejs
		*/
		requirejs: {
			client: {
				options: {
					baseUrl: 'multi/client',
					out: 'public/js/lib/multi.js',
					name: 'index',
					wrap: {
						end: 'define(["index"], function(index) { return index; });'
					},
					optimize: 'none'
				}
			}
		},

		// client side testing
		qunit: {
			files: ['tests/client/**/*.html']
		},

		watch: {
			// test js files on file change
			all: {
				files: ['Gruntfile.js', 'app.js', 'package.json', 'multi/**/*.js', 'tests/**/*.js'],
				tasks: ['jshint'],
				options: {
					spawn: false
				}
			},
			// build and test client lib on file change
			client: {
				files: ['multi/client/**/*.js', 'multi/shared/**/*.js'],
				tasks: ['requirejs:client', 'qunit', 'qunitShared']
			},
			// test server lib on file change
			server: {
				files: ['multi/server/**/*.js', 'multi/shared/**/*.js'],
				tasks: ['qunitServer', 'qunitShared']
			},
			// test server on test change
			testsServer: {
				files: ['tests/server/**/*.js'],
				tasks: ['qunitServer']
			},
			// test shared on test change
			testsShared: {
				files: ['tests/shared/**/*.js'],
				tasks: ['qunitShared']
			},
			// test client on test change
			testsClient: {
				files: ['tests/client/**/*.js'],
				tasks: ['qunit']
			}
		}
	});

	grunt.loadNpmTasks('grunt-jsdoc');
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-qunit');
	grunt.loadNpmTasks('grunt-contrib-watch');
	grunt.loadNpmTasks('grunt-contrib-requirejs');

	// on watch events configure jshint to only run on changed file
	grunt.event.on('watch', function(action, filepath) {
		grunt.config('jshint.files', filepath);
	});

	function filterQunitResult(error, result, code) {
		if (error) {
			grunt.log.error(error);
		} else {
			if (result.toString().indexOf("Error") !== -1) {
				grunt.log.write(result + '\n');
				throw 'Something above threw an error \u2191';
{'fraction_non_alphanumeric': 0.19524184034604797, 'fraction_numerical': 0.001966181675186787, 'mean_word_length': 2.7185672514619883, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 2, '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': '705019', 'n_tokens_mistral': 2206, 'n_tokens_neox': 1771, 'n_words': 377}