Grunt: limit JSHint's run to a single specified file. Run with grunt jshint:core --file=filename.js. Props kadamwhite, see #25187.

git-svn-id: https://develop.svn.wordpress.org/trunk@26043 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2013-11-08 00:40:38 +00:00
parent 3a5802dd3b
commit 3032512477
1 changed files with 20 additions and 0 deletions

View File

@ -123,6 +123,26 @@ module.exports = function(grunt) {
options: {
curly: false,
eqeqeq: false
},
// Limit JSHint's run to a single specified file
// grunt jshint:core --file=filename.js
filter: function( filepath ) {
var file = grunt.option( 'file' );
// Don't filter when no target file is specified
if ( ! file ) {
return true;
}
// Normalize filepath for Windows
filepath = filepath.replace( /\\/g, '/' );
// Match only the filename passed from cli
if ( filepath.lastIndexOf( '/' + file ) === filepath.length - ( file.length + 1 ) ) {
return true;
}
return false;
}
}
},