Make WordPress Core

Changeset 41708


Ignore:
Timestamp:
10/03/2017 03:19:23 PM (7 years ago)
Author:
azaozz
Message:

Tools: enable Grunt precommit task to run without requiring SVN or GIT.

Fixes #41957

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Gruntfile.js

    r41701 r41708  
    840840                } );
    841841            } else {
    842                 grunt.fatal( 'This WordPress install is not under version control.' );
    843             }
     842                runAllTasks();
     843            }
     844        }
     845
     846        function runAllTasks() {
     847            grunt.log.writeln( 'Cannot determine which files are modified as SVN and GIT are not available.' );
     848            grunt.log.writeln( 'Running all tasks and all tests.' );
     849            grunt.task.run([
     850                'precommit:js',
     851                'precommit:css',
     852                'precommit:image',
     853                'precommit:emoji',
     854                'precommit:php'
     855            ]);
     856
     857            done();
    844858        }
    845859
     
    853867                var taskList = [];
    854868
    855                 if ( code !== 0 ) {
    856                     grunt.fatal( 'The `' +  map[ type ] + '` command returned a non-zero exit code.', code );
    857                 }
    858 
    859869                // Callback for finding modified paths.
    860870                function testPath( path ) {
     
    869879                }
    870880
    871                 if ( [ 'package.json', 'Gruntfile.js' ].some( testPath ) ) {
    872                     grunt.log.writeln( 'Configuration files modified. Running `prerelease`.' );
    873                     taskList.push( 'prerelease' );
     881                if ( code === 0 ) {
     882                    if ( [ 'package.json', 'Gruntfile.js' ].some( testPath ) ) {
     883                        grunt.log.writeln( 'Configuration files modified. Running `prerelease`.' );
     884                        taskList.push( 'prerelease' );
     885                    } else {
     886                        if ( [ 'png', 'jpg', 'gif', 'jpeg' ].some( testExtension ) ) {
     887                            grunt.log.writeln( 'Image files modified. Minifying.' );
     888                            taskList.push( 'precommit:image' );
     889                        }
     890
     891                        [ 'js', 'css', 'php' ].forEach( function( extension ) {
     892                            if ( testExtension( extension ) ) {
     893                                grunt.log.writeln( extension.toUpperCase() + ' files modified. ' + extension.toUpperCase() + ' tests will be run.' );
     894                                taskList.push( 'precommit:' + extension );
     895                            }
     896                        } );
     897
     898                        if ( [ 'twemoji.js' ].some( testPath ) ) {
     899                            grunt.log.writeln( 'twemoji.js has updated. Running `precommit:emoji.' );
     900                            taskList.push( 'precommit:emoji' );
     901                        }
     902                    }
     903
     904                    grunt.task.run( taskList );
     905                    done();
    874906                } else {
    875                     if ( [ 'png', 'jpg', 'gif', 'jpeg' ].some( testExtension ) ) {
    876                         grunt.log.writeln( 'Image files modified. Minifying.' );
    877                         taskList.push( 'precommit:image' );
    878                     }
    879 
    880                     [ 'js', 'css', 'php' ].forEach( function( extension ) {
    881                         if ( testExtension( extension ) ) {
    882                             grunt.log.writeln( extension.toUpperCase() + ' files modified. ' + extension.toUpperCase() + ' tests will be run.' );
    883                             taskList.push( 'precommit:' + extension );
    884                         }
    885                     } );
    886 
    887                     if ( [ 'twemoji.js' ].some( testPath ) ) {
    888                         grunt.log.writeln( 'twemoji.js has updated. Running `precommit:emoji.' );
    889                         taskList.push( 'precommit:emoji' );
    890                     }
    891                 }
    892 
    893                 grunt.task.run( taskList );
    894 
    895                 done();
     907                    runAllTasks();
     908                }
    896909            } );
    897910        }
Note: See TracChangeset for help on using the changeset viewer.