From 72a61e941d5e39ad6ef93a84c0af2e8437dd2fa1 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sat, 21 Jun 2014 20:02:47 +0000 Subject: [PATCH] Add a `grunt jshint:plugins` task. Props MattyRob. Fixes #28464. git-svn-id: https://develop.svn.wordpress.org/trunk@28798 602fd350-edb4-49c9-b593-d223f7449a82 --- Gruntfile.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Gruntfile.js b/Gruntfile.js index 6d18811cb5..056ee549d4 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -271,6 +271,36 @@ module.exports = function(grunt) { return true; } + return false; + } + }, + plugins: { + expand: true, + cwd: SOURCE_DIR + 'wp-content/plugins', + src: [ + '**/*.js', + '!**/*.min.js' + ], + // Limit JSHint's run to a single specified plugin folder: + // + // grunt jshint:plugins --folder=foldername + // + filter: function( folderpath ) { + var index, folder = grunt.option( 'folder' ); + + // Don't filter when no target folder is specified + if ( ! folder ) { + return true; + } + + folderpath = folderpath.replace( /\\/g, '/' ); + index = folderpath.lastIndexOf( '/' + folder ); + + // Match only the folder name passed from cli + if ( -1 !== index ) { + return true; + } + return false; } }