Make WordPress Core

Changeset 43327


Ignore:
Timestamp:
05/29/2018 02:20:44 PM (8 years ago)
Author:
azaozz
Message:

Build tools: Grunt:

  • Normalize filepath in the the watch event.
  • Throw a warning when watch fails to process a file because the destination path cannot be determined.

Fixes #44262.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Gruntfile.js

    r43324 r43327  
    13561356         * so that only the changed files are updated.
    13571357         */
    1358         grunt.event.on('watch', function( action, filepath, target ) {
     1358        grunt.event.on( 'watch', function( action, filepath, target ) {
    13591359                var src;
    13601360
     
    13631363                        return;
    13641364                }
     1365
     1366                // Normalize filepath for Windows.
     1367                filepath = filepath.replace( /\\/g, '/' );
    13651368
    13661369                // If the target is a file in the restructured js src.
     
    13931396                                        grunt.config( [ 'copy', 'includes-js', 'files' ] )
    13941397                                );
     1398
    13951399                                for ( dest in configs ) {
    13961400                                        // If a file in the mapping matches then set the variables for our dynamic tasks.
    1397                                         if ( configs.hasOwnProperty( dest ) && configs[ dest ][0] === './' + filepath ) {
     1401                                        if ( dest && configs.hasOwnProperty( dest ) && configs[ dest ][0] === './' + filepath ) {
    13981402                                                files[ dest ] = configs[ dest ];
    13991403                                                src = [ path.relative( BUILD_DIR, dest ) ];
     
    14201424                }
    14211425
     1426                if ( ! src ) {
     1427                        grunt.warn( 'Failed to determine the destination file.' );
     1428                        return;
     1429                }
     1430
    14221431                if ( action === 'deleted' ) {
    14231432                        // Clean up only those files that were deleted.
Note: See TracChangeset for help on using the changeset viewer.