Make WordPress Core

Ticket #29546: 29546v2.diff

File 29546v2.diff, 1.6 KB (added by MattyRob, 12 years ago)
  • Gruntfile.js

     
    22module.exports = function(grunt) {
    33        var path = require('path'),
    44                SOURCE_DIR = 'src/',
    5                 BUILD_DIR = 'build/';
     5                BUILD_DIR = 'build/',
     6                DIR_ERROR = 'No plugin directory specified, use --dir=foldername';
    67
    78        // Load tasks.
    89        require('matchdep').filterDev(['grunt-*', '!grunt-legacy-util']).forEach( grunt.loadNpmTasks );
    … …  
    293294
    294295                                        // Don't filter when no target folder is specified
    295296                                        if ( ! dir ) {
    296                                                 return true;
     297                                                grunt.fail.fatal(DIR_ERROR);
    297298                                        }
    298299
    299300                                        dirpath = dirpath.replace( /\\/g, '/' );
    … …  
    351352                                        '!wp-includes/js/underscore.min.js',
    352353                                        '!wp-includes/js/zxcvbn.min.js'
    353354                                ]
     355                        },
     356                        plugins: {
     357                                expand: true,
     358                                cwd: SOURCE_DIR + 'wp-content/plugins',
     359                                dest: BUILD_DIR,
     360                                ext: '.min.js',
     361                                src: [
     362                                        '**/*.js',
     363                                        '!**/*.min.js'
     364                                ],
     365                                // Limit Uglify's run to a single specified plugin directory:
     366                                //
     367                                //    grunt uglify:plugins --dir=foldername
     368                                //
     369                                filter: function( dirpath ) {
     370                                        var index, dir = grunt.option( 'dir' );
     371
     372                                        // Don't filter when no target folder is specified
     373                                        if ( ! dir ) {
     374                                                grunt.fail.fatal(DIR_ERROR);
     375                                        }
     376
     377                                        dirpath = dirpath.replace( /\\/g, '/' );
     378                                        index = dirpath.lastIndexOf( '/' + dir );
     379
     380                                        // Match only the folder name passed from cli
     381                                        if ( -1 !== index ) {
     382                                                return true;
     383                                        }
     384
     385                                        return false;
     386                                }
    354387                        }
    355388                },
    356389                concat: {