diff --git a/Gruntfile.js b/Gruntfile.js index d4a2271307..6b2b6f3dba 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -668,7 +668,7 @@ module.exports = function(grunt) { grunt.task.run( '_' + this.nameArgs ); } ); - grunt.registerTask( 'precommit:base', [ + grunt.registerTask( 'precommit:image', [ 'imagemin:core' ] ); @@ -714,16 +714,24 @@ module.exports = function(grunt) { function run( type ) { var command = map[ type ].split( ' ' ); - var taskList = [ 'precommit:base' ]; grunt.util.spawn( { cmd: command.shift(), args: command }, function( error, result, code ) { + var taskList = []; + if ( code !== 0 ) { grunt.fatal( 'The `' + map[ type ] + '` command returned a non-zero exit code.', code ); } + [ 'png', 'jpg', 'gif', 'jpeg' ].forEach( function( extension ) { + if ( ( result.stdout + '\n' ).indexOf( '.' + extension + '\n' ) !== -1 ) { + grunt.log.writeln( 'Image files modified. Minifying.'); + taskList.push( 'precommit:image' ); + } + } ); + [ 'js', 'css', 'php' ].forEach( function( extension ) { if ( ( result.stdout + '\n' ).indexOf( '.' + extension + '\n' ) !== -1 ) { grunt.log.writeln( extension.toUpperCase() + ' files modified. ' + extension.toUpperCase() + ' tests will be run.'); @@ -769,7 +777,7 @@ module.exports = function(grunt) { 'precommit:php', 'precommit:js', 'precommit:css', - 'precommit:base' + 'precommit:image' ] ); // Testing tasks.