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:
parent
3a5802dd3b
commit
3032512477
20
Gruntfile.js
20
Gruntfile.js
@ -123,6 +123,26 @@ module.exports = function(grunt) {
|
|||||||
options: {
|
options: {
|
||||||
curly: false,
|
curly: false,
|
||||||
eqeqeq: 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user