mirror of
git://develop.git.wordpress.org/
synced 2025-01-16 20:38:35 +01:00
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: {
|
||||
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;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user