Make WordPress Core

Changeset 26168


Ignore:
Timestamp:
11/14/2013 06:16:59 PM (11 years ago)
Author:
azaozz
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Gruntfile.js

    r26145 r26168  
    55        BUILD_DIR = 'build/';
    66
    7     // Load tasks. 
     7    // Load tasks.
    88    require('matchdep').filterDev('grunt-*').forEach( grunt.loadNpmTasks );
    99
     
    205205                //     grunt jshint:core --file=filename.js
    206206                filter: function( filepath ) {
    207                     var file = grunt.option( 'file' );
     207                    var index, file = grunt.option( 'file' );
    208208
    209209                    // Don't filter when no target file is specified
     
    214214                    // Normalize filepath for Windows
    215215                    filepath = filepath.replace( /\\/g, '/' );
     216                    index = filepath.lastIndexOf( '/' + file );
    216217
    217218                    // Match only the filename passed from cli
    218                     if ( filepath.lastIndexOf( '/' + file ) === filepath.length - ( file.length + 1 ) ) {
     219                    if ( filepath === file || ( -1 !== index && index === filepath.length - ( file.length + 1 ) ) ) {
    219220                        return true;
    220221                    }
Note: See TracChangeset for help on using the changeset viewer.