Grunt jshint: ensure the file passed with --file=filename.js matches all or part of the filepath before checking string lengths. Makes it possible to pass a file with full or partial path. All of these would work properly:
admin-bar.js, wp-includes/js/admin-bar.js, src/wp-includes/js/admin-bar.js. Props atimmer, fixes #25992. git-svn-id: https://develop.svn.wordpress.org/trunk@26168 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
cf748f9c6d
commit
518cac37de
@ -4,7 +4,7 @@ module.exports = function(grunt) {
|
||||
SOURCE_DIR = 'src/',
|
||||
BUILD_DIR = 'build/';
|
||||
|
||||
// Load tasks.
|
||||
// Load tasks.
|
||||
require('matchdep').filterDev('grunt-*').forEach( grunt.loadNpmTasks );
|
||||
|
||||
// Project configuration.
|
||||
@ -204,7 +204,7 @@ module.exports = function(grunt) {
|
||||
// Limit JSHint's run to a single specified file
|
||||
// grunt jshint:core --file=filename.js
|
||||
filter: function( filepath ) {
|
||||
var file = grunt.option( 'file' );
|
||||
var index, file = grunt.option( 'file' );
|
||||
|
||||
// Don't filter when no target file is specified
|
||||
if ( ! file ) {
|
||||
@ -213,9 +213,10 @@ module.exports = function(grunt) {
|
||||
|
||||
// Normalize filepath for Windows
|
||||
filepath = filepath.replace( /\\/g, '/' );
|
||||
index = filepath.lastIndexOf( '/' + file );
|
||||
|
||||
// Match only the filename passed from cli
|
||||
if ( filepath.lastIndexOf( '/' + file ) === filepath.length - ( file.length + 1 ) ) {
|
||||
if ( filepath === file || ( -1 !== index && index === filepath.length - ( file.length + 1 ) ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user