tasks/lib/javascript.js
function(files, config, catalog, env) {
		var uglifyConfig = this.uglifyConfig(config, env);
		var grunt = env.grunt;
		var _ = grunt.util._;

		files.forEach(function(f) {
			var src = validFiles(f.src, grunt, config);
			var dest = utils.fileInfo(f.dest, config);
			grunt.log.write('Processing ' + dest.catalogPath.cyan);

			// check if current file should be compiled
			if (!shouldProcess(dest, src, config, catalog)) {
				grunt.log.writeln(' [skip]'.grey);
				return false;
			}

			grunt.verbose.writeln('');
			if (config.minify) {
				grunt.verbose.writeln('Minifying JS files');
				var uglified = uglify.minify(_.pluck(src, '_path'), dest.absPath, uglifyConfig);
				dest.content = uglified.code;
			} else {
				dest.content = _.pluck(src, '_path')
					.map(function(src) {
						return grunt.file.read(src);
					})
					.join('');
			}

			if (config.postProcess) {
				dest.content = config.postProcess(dest.content, dest);
			}

			grunt.file.write(dest.absPath, dest.content);

			// Otherwise, print a success message....
			grunt.log.writeln(' [save]'.green);

			// update catalog entry
			catalog[dest.catalogPath] = {
				hash: dest.hash,
				date: utils.timestamp(),
				versioned: dest.versionedUrl(config),
				files: src.map(function(f) {
					return {
						file: f.catalogPath,
						hash: f.hash,
						versioned: f.versionedUrl(config)
					};
				}, this)
			};
		});

		return catalog;
	}
function(files, config, catalog, env) {
		var uglifyConfig = this.uglifyConfig(config, env);
		var grunt = env.grunt;
		var _ = grunt.util._;

		files.forEach(function(f) {
			var src = validFiles(f.src, grunt, config);
			var dest = utils.fileInfo(f.dest, config);
			grunt.log.write('Processing ' + dest.catalogPath.cyan);

			// check if current file should be compiled
			if (!shouldProcess(dest, src, config, catalog)) {
				grunt.log.writeln(' [skip]'.grey);
				return false;
			}

			grunt.verbose.writeln('');
			if (config.minify) {
				grunt.verbose.writeln('Minifying JS files');
				var uglified = uglify.minify(_.pluck(src, '_path'), dest.absPath, uglifyConfig);
				dest.content = uglified.code;
			} else {
				dest.content = _.pluck(src, '_path')
					.map(function(src) {
						return grunt.file.read(src);
					})
					.join('');
			}

			if (config.postProcess) {
				dest.content = config.postProcess(dest.content, dest);
			}

			grunt.file.write(dest.absPath, dest.content);

			// Otherwise, print a success message....
			grunt.log.writeln(' [save]'.green);

			// update catalog entry
			catalog[dest.catalogPath] = {
				hash: dest.hash,
				date: utils.timestamp(),
				versioned: dest.versionedUrl(config),
				files: src.map(function(f) {
					return {
						file: f.catalogPath,
						hash: f.hash,
						versioned: f.versionedUrl(config)
					};
				}, this)
			};
		});

		return catalog;
	}
function ( files , config , catalog , env ) { var uglifyConfig = this . uglifyConfig ( config , env ) ; var grunt = env . grunt ; var _ = grunt . util . _ ; files . forEach ( function ( f ) { var src = validFiles ( f . src , grunt , config ) ; var dest = utils . fileInfo ( f . dest , config ) ; grunt . log . write ( 'Processing ' + dest . catalogPath . cyan ) ; // check if current file should be compiled if ( ! shouldProcess ( dest , src , config , catalog ) ) { grunt . log . writeln ( ' [skip]' . grey ) ; return false ; } grunt . verbose . writeln ( '' ) ; if ( config . minify ) { grunt . verbose . writeln ( 'Minifying JS files' ) ; var uglified = uglify . minify ( _ . pluck ( src , '_path' ) , dest . absPath , uglifyConfig ) ; dest . content = uglified . code ; } else { dest . content = _ . pluck ( src , '_path' ) . map ( function ( src ) { return grunt . file . read ( src ) ; } ) . join ( '' ) ; } if ( config . postProcess ) { dest . content = config . postProcess ( dest . content , dest ) ; } grunt . file . write ( dest . absPath , dest . content ) ; // Otherwise, print a success message.... grunt . log . writeln ( ' [save]' . green ) ; // update catalog entry catalog [ dest . catalogPath ] = { hash : dest . hash , date : utils . timestamp ( ) , versioned : dest . versionedUrl ( config ) , files : src . map ( function ( f ) { return { file : f . catalogPath , hash : f . hash , versioned : f . versionedUrl ( config ) } ; } , this ) } ; } ) ; return catalog ; }
Processes given JS files
@param  {Array} files    Normalized Grunt task file list
@param  {Object} config  Current task config
@param  {Object} catalog Output catalog
@param  {Object} env     Task environment (`grunt` and `task` properties)
@return {Object}         Updated catalog
Processes given JS files