<commit_before>/**
 * Tâmia workflow for Grunt.
 * JavaScript stuff: concatenation, minification, linting. Plus Bower concatenation and Modernizr custom build.
 *
 * @author <NAME> (http://sapegin.me)
 */

// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
module.exports = function(grunt, util, config) {
	'use strict';

	// @todo Run bower_concat if bower.json exists.

	var _ = require('lodash');

	if (!grunt.file.exists('js/main.js')) return config;

	if (!config.concat) {
		grunt.fail.fatal('Gruntfile should contain "concat" section.');
		return;
	}

	var debug = !!grunt.option('debug');

	var localConfig = {
		jshint: {
			options: {
				jshintrc: true
			},
			files: [
				'js/*.js',
				'js/components/*.js'
			]
		},
		bower_concat: {
			main: {
				dest: 'build/_bower.js',
				exclude: [
					'jquery',
					'modernizr'
				]
			}
		},
		uglify: {
			options: {
				compress: {
					global_defs: {
						DEBUG: debug
					}
				}
			},
			main: {
				options: {
					banner: '<%= banner %>'
				},
				files: {
					'<%= concat.main.dest %>': '<%= concat.main.dest %>'
				}
			}
		},
		modernizr: {
			main: {
				devFile: 'remote',
				outputFile: 'build/modernizr.js',
				extra: {
					load: false
				},
				files: {
					src: [
						'build/scripts.js',
						'build/styles.css'
					]
				}
			}
		},
		watch: {
			concat: {
				options: {
					atBegin: true
				},
				files: '<%= concat.main.src %>',
				tasks: ['concat']
			},
			bower: {
				files: 'bower.json',
				tasks: ['bower_concat', 'concat']
			}
		}
	};

	config = _.merge(localConfig, config);

	util.npmDependencies([
		'grunt-contrib-jshint',
		'grunt-bower-concat',
		'grunt-contrib-concat',
		'grunt-contrib-uglify',
		'grunt-modernizr'
	]);
	util.requireBanner();

	grunt.registerTask('scripts', ['jshint', 'bower_concat', 'concat', 'uglify', 'modernizr']);

	return config;
};<commit_msg>Run bower_concat only if bower.json exists.<commit_after>/**
 * Tâmia workflow for Grunt.
 * JavaScript stuff: concatenation, minification, linting. Plus Bower concatenation and Modernizr custom build.
 *
 * @author <NAME> (http://sapegin.me)
 */

// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
module.exports = function(grunt, util, config) {
	'use strict';

	var _ = require('lodash');

	if (!grunt.file.exists('js/main.js')) return config;

	if (!config.concat) {
		grunt.fail.fatal('Gruntfile should contain "concat" section.');
		return;
	}

	var debug = !!grunt.option('debug');

	var localConfig = {
		jshint: {
			options: {
				jshintrc: true
			},
			files: [
				'js/*.js',
				'js/components/*.js'
			]
		},
		uglify: {
			options: {
				compress: {
					global_defs: {
						DEBUG: debug
					}
				}
			},
			main: {
				options: {
					banner: '<%= banner %>'
				},
				files: {
					'<%= concat.main.dest %>': '<%= concat.main.dest %>'
				}
			}
		},
		modernizr: {
			main: {
				devFile: 'remote',
				outputFile: 'build/modernizr.js',
				extra: {
					load: false
				},
				files: {
					src: [
						'build/scripts.js',
						'build/styles.css'
					]
				}
			}
		},
		watch: {
			concat: {
				options: {
					atBegin: true
				},
				files: '<%= concat.main.src %>',
				tasks: ['concat']
			}
		}
	};

	var deps = [
		'grunt-contrib-jshint',
		'grunt-contrib-concat',
		'grunt-contrib-uglify',
		'grunt-modernizr'
	];

	var tasks = ['jshint', 'concat', 'uglify', 'modernizr'];

	if (grunt.file.exists('bower.json')) {
		localConfig.bower_concat = {
			main: {
				dest: 'build/_bower.js',
				exclude: [
					'jquery',
					'modernizr'
				]
			}
		};
		localConfig.watch.bower = {
			files: 'bower.json',
			tasks: ['bower_concat', 'concat']
		};
		deps.push('grunt-bower-concat');
		tasks.splice(tasks.indexOf('jshint') + 1, 0, 'bower_concat');
	}

	config = _.merge(localConfig, config);

	util.npmDependencies(deps);
	util.requireBanner();

	grunt.registerTask('scripts', tasks);

	return config;
};
{'fraction_non_alphanumeric': 0.17850776674306085, 'fraction_numerical': 0.0005092946269416857, 'mean_word_length': 2.6069788797061526, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '2712551', 'n_tokens_mistral': 1890, 'n_tokens_neox': 1482, 'n_words': 261}