Build/Test Tools: Run prerelease as the precommit task for configuration file changes

Whenever package.json or Gruntfile.js is updated, we should assume that it affects everything and run the full monty of tasks.

Fixes #36528.
Props iseulde.



git-svn-id: https://develop.svn.wordpress.org/trunk@37650 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Aaron Jorbin 2016-06-07 03:32:22 +00:00
parent a1e19248a3
commit 8ad4a72960

View File

@ -725,19 +725,26 @@ module.exports = function(grunt) {
grunt.fatal( 'The `' + map[ type ] + '` command returned a non-zero exit code.', code ); grunt.fatal( 'The `' + map[ type ] + '` command returned a non-zero exit code.', code );
} }
[ 'png', 'jpg', 'gif', 'jpeg' ].forEach( function( extension ) { if ( [ 'package.json', 'Gruntfile.js' ].some( function( path ) {
if ( ( result.stdout + '\n' ).indexOf( '.' + extension + '\n' ) !== -1 ) { return ( result.stdout + '\n' ).indexOf( ' ' + path + '\n' ) !== -1;
grunt.log.writeln( 'Image files modified. Minifying.'); } ) ) {
grunt.log.writeln( 'Configuration files modified. Running `prerelease`.' );
taskList.push( 'prerelease' );
} else {
if ( [ 'png', 'jpg', 'gif', 'jpeg' ].some( function( extension ) {
return ( result.stdout + '\n' ).indexOf( '.' + extension + '\n' ) !== -1;
} ) ) {
grunt.log.writeln( 'Image files modified. Minifying.' );
taskList.push( 'precommit:image' ); taskList.push( 'precommit:image' );
} }
} );
[ 'js', 'css', 'php' ].forEach( function( extension ) { [ 'js', 'css', 'php' ].forEach( function( extension ) {
if ( ( result.stdout + '\n' ).indexOf( '.' + extension + '\n' ) !== -1 ) { if ( ( result.stdout + '\n' ).indexOf( '.' + extension + '\n' ) !== -1 ) {
grunt.log.writeln( extension.toUpperCase() + ' files modified. ' + extension.toUpperCase() + ' tests will be run.'); grunt.log.writeln( extension.toUpperCase() + ' files modified. ' + extension.toUpperCase() + ' tests will be run.' );
taskList.push( 'precommit:' + extension ); taskList.push( 'precommit:' + extension );
} }
} ); } );
}
grunt.task.run( taskList ); grunt.task.run( taskList );