Ticket #29546: 29546v2.diff
| File 29546v2.diff, 1.6 KB (added by , 12 years ago) |
|---|
-
Gruntfile.js
2 2 module.exports = function(grunt) { 3 3 var path = require('path'), 4 4 SOURCE_DIR = 'src/', 5 BUILD_DIR = 'build/'; 5 BUILD_DIR = 'build/', 6 DIR_ERROR = 'No plugin directory specified, use --dir=foldername'; 6 7 7 8 // Load tasks. 8 9 require('matchdep').filterDev(['grunt-*', '!grunt-legacy-util']).forEach( grunt.loadNpmTasks ); … … 293 294 294 295 // Don't filter when no target folder is specified 295 296 if ( ! dir ) { 296 return true;297 grunt.fail.fatal(DIR_ERROR); 297 298 } 298 299 299 300 dirpath = dirpath.replace( /\\/g, '/' ); … … 351 352 '!wp-includes/js/underscore.min.js', 352 353 '!wp-includes/js/zxcvbn.min.js' 353 354 ] 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 } 354 387 } 355 388 }, 356 389 concat: {