From 8ad4a72960d84220c1f806a19dbf7f708f9980d7 Mon Sep 17 00:00:00 2001 From: Aaron Jorbin Date: Tue, 7 Jun 2016 03:32:22 +0000 Subject: [PATCH] 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 --- Gruntfile.js | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 6b2b6f3dba..f008a51e47 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -725,19 +725,26 @@ module.exports = function(grunt) { 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.'); + if ( [ 'package.json', 'Gruntfile.js' ].some( function( path ) { + return ( result.stdout + '\n' ).indexOf( ' ' + path + '\n' ) !== -1; + } ) ) { + 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' ); } - } ); - [ '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.'); - taskList.push( 'precommit:' + extension ); - } - } ); + [ '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.' ); + taskList.push( 'precommit:' + extension ); + } + } ); + } grunt.task.run( taskList );