Make WordPress Core

Changeset 37211


Ignore:
Timestamp:
04/15/2016 10:18:03 AM (8 years ago)
Author:
iseulde
Message:

Build/Test Tools: Run image tasks only if there are changes

See #36528.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Gruntfile.js

    r37206 r37211  
    669669    } );
    670670
    671     grunt.registerTask( 'precommit:base', [
     671    grunt.registerTask( 'precommit:image', [
    672672        'imagemin:core'
    673673    ] );
     
    715715        function run( type ) {
    716716            var command = map[ type ].split( ' ' );
    717             var taskList = [ 'precommit:base' ];
    718717
    719718            grunt.util.spawn( {
     
    721720                args: command
    722721            }, function( error, result, code ) {
     722                var taskList = [];
     723
    723724                if ( code !== 0 ) {
    724725                    grunt.fatal( 'The `' +  map[ type ] + '` command returned a non-zero exit code.', code );
    725726                }
     727
     728                [ 'png', 'jpg', 'gif', 'jpeg' ].forEach( function( extension ) {
     729                    if ( ( result.stdout + '\n' ).indexOf( '.' + extension + '\n' ) !== -1 ) {
     730                        grunt.log.writeln( 'Image files modified. Minifying.');
     731                        taskList.push( 'precommit:image' );
     732                    }
     733                } );
    726734
    727735                [ 'js', 'css', 'php' ].forEach( function( extension ) {
     
    770778        'precommit:js',
    771779        'precommit:css',
    772         'precommit:base'
     780        'precommit:image'
    773781    ] );
    774782
Note: See TracChangeset for help on using the changeset viewer.