{"size": 2349, "ext": "js", "max_stars_repo_path": "grunt.js", "max_stars_repo_name": "jaubourg/ajaxHooks", "max_stars_repo_stars_event_min_datetime": "2015-01-21T13:01:37.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-28T02:11:06.000Z", "max_issues_repo_path": "grunt.js", "max_issues_repo_name": "lkiarest/ajaxHooks", "max_issues_repo_issues_event_min_datetime": "2015-05-28T06:59:20.000Z", "max_issues_repo_issues_event_max_datetime": "2015-05-28T06:59:20.000Z", "max_forks_repo_path": "grunt.js", "max_forks_repo_name": "lkiarest/ajaxHooks", "max_forks_repo_forks_event_min_datetime": "2015-02-15T15:19:11.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-11T10:07:19.000Z"}
{"max_stars_count": 51, "max_issues_count": 1, "max_forks_count": 29, "avg_line_length": 21.953271028, "max_line_length": 84, "alphanum_fraction": 0.595146871}
/**
 * Resources
 *
 * https://gist.github.com/2489540
 *
 */

/*jshint node: true */
/*global config:true, task:true, process:true*/
module.exports = function( grunt ) {

	// readOptionalJSON
	// by Ben Alman
	// https://gist.github.com/2876125
	function readOptionalJSON( filepath ) {
		var data = {};
		try {
			data = grunt.file.readJSON( filepath );
			grunt.verbose.write( "Reading " + filepath + "..." ).ok();
		} catch(e) {}
		return data;
	}
	
	function jshintrc( path ) {
		return readOptionalJSON( ( path || "" ) + ".jshintrc" ) || {};
	}

	var distpaths = [
			"dist/ajaxhooks.js",
			"dist/ajaxhooks.min.js"
		],
		files = (function() {
			var files = [ "build/intro.js" ];
			grunt.file.recurse( "src", function( path ) {
				if ( /\.js$/.test( path ) ) {
					files.push( path );
				}
			});
			files.push( "build/outro.js" );
			return files;
		})();

	grunt.initConfig({
		pkg: "<json:package.json>",
		dst: "dist",
		build: {
			"dist/ajaxhooks.js": files
		},
		min: {
			"dist/ajaxhooks.min.js": [ "dist/ajaxhooks.js" ]
		},
		lint: {
			src: "src/*.js",
			dist: "dist/ajaxhooks.js",
			tests: "test/unit/*.js",
			grunt: "grunt.js"
		},
		jshint: {
			options: jshintrc(),
			src: jshintrc( "src/" ),
			dist: jshintrc( "src/" ),
			tests: jshintrc( "test/" )
		},
		uglify: {}
	});

	grunt.loadNpmTasks("grunt-update-submodules");

	grunt.registerTask( "default", "update_submodules build lint min" );

	grunt.registerMultiTask(
		"build",
		"Concatenate source (include/exclude modules with +/- flags), embed date/version",
		function() {
			// Concat specified files.
			var name = this.file.dest,
				version = grunt.config( "pkg.version" ),
				compiled = "";

			// append commit id to version
			if ( process.env.COMMIT ) {
				version += "-" + process.env.COMMIT;
			}

			// conditionally concatenate source
			this.file.src.forEach(function( filepath ) {
				compiled += grunt.file.read( filepath );
			});

			// Embed Date
			// Embed Version
			compiled = compiled.replace( "@DATE", new Date() )
				.replace( /@VERSION/g, version );

			// Write concatenated source to file
			grunt.file.write( name, compiled );

			// Fail task if errors were logged.
			if ( this.errorCount ) {
				return false;
			}

			// Otherwise, print a success message.
			grunt.log.writeln( "File '" + name + "' created." );
		});
};
