Make WordPress Core

Ticket #41957: 41957.patch

File 41957.patch, 2.7 KB (added by azaozz, 6 years ago)
  • Gruntfile.js

     
    875875                        }, function( error, result, code ) {
    876876                                var taskList = [];
    877877
    878                                 if ( code !== 0 ) {
    879                                         grunt.fatal( 'The `' +  map[ type ] + '` command returned a non-zero exit code.', code );
    880                                 }
    881 
    882878                                // Callback for finding modified paths.
    883879                                function testPath( path ) {
    884880                                        var regex = new RegExp( ' ' + path + '$', 'm' );
     
    891887                                        return regex.test( result.stdout );
    892888                                }
    893889
    894                                 if ( [ 'package.json', 'Gruntfile.js' ].some( testPath ) ) {
    895                                         grunt.log.writeln( 'Configuration files modified. Running `prerelease`.' );
    896                                         taskList.push( 'prerelease' );
    897                                 } else {
    898                                         if ( [ 'png', 'jpg', 'gif', 'jpeg' ].some( testExtension ) ) {
    899                                                 grunt.log.writeln( 'Image files modified. Minifying.' );
    900                                                 taskList.push( 'precommit:image' );
    901                                         }
    902 
    903                                         [ 'js', 'css', 'php' ].forEach( function( extension ) {
    904                                                 if ( testExtension( extension ) ) {
    905                                                         grunt.log.writeln( extension.toUpperCase() + ' files modified. ' + extension.toUpperCase() + ' tests will be run.' );
    906                                                         taskList.push( 'precommit:' + extension );
     890                                if ( code === 0 ) {
     891                                        if ( [ 'package.json', 'Gruntfile.js' ].some( testPath ) ) {
     892                                                grunt.log.writeln( 'Configuration files modified. Running `prerelease`.' );
     893                                                taskList.push( 'prerelease' );
     894                                        } else {
     895                                                if ( [ 'png', 'jpg', 'gif', 'jpeg' ].some( testExtension ) ) {
     896                                                        grunt.log.writeln( 'Image files modified. Minifying.' );
     897                                                        taskList.push( 'precommit:image' );
    907898                                                }
    908                                         } );
    909 
    910                                         if ( [ 'twemoji.js' ].some( testPath ) ) {
    911                                                 grunt.log.writeln( 'twemoji.js has updated. Running `precommit:emoji.' );
    912                                                 taskList.push( 'precommit:emoji' );
     899       
     900                                                [ 'js', 'css', 'php' ].forEach( function( extension ) {
     901                                                        if ( testExtension( extension ) ) {
     902                                                                grunt.log.writeln( extension.toUpperCase() + ' files modified. ' + extension.toUpperCase() + ' tests will be run.' );
     903                                                                taskList.push( 'precommit:' + extension );
     904                                                        }
     905                                                } );
     906       
     907                                                if ( [ 'twemoji.js' ].some( testPath ) ) {
     908                                                        grunt.log.writeln( 'twemoji.js has updated. Running `precommit:emoji.' );
     909                                                        taskList.push( 'precommit:emoji' );
     910                                                }
    913911                                        }
     912                                } else {
     913                                        grunt.log.writeln( 'Cannot determine which files are modified as SVN and GIT are not accessible.' );
     914                                        grunt.log.writeln( 'Running all tasks and all tests.' );
     915                                        taskList.push(
     916                                                'precommit:js',
     917                                                'precommit:css',
     918                                                'precommit:image',
     919                                                'precommit:emoji',
     920                                                'precommit:php'
     921                                        );
    914922                                }
    915923
    916924                                grunt.task.run( taskList );