| 666 | | // Add a listener to the watch task. |
| 667 | | // |
| 668 | | // On `watch:all`, automatically updates the `copy:dynamic` and `clean:dynamic` |
| 669 | | // configurations so that only the changed files are updated. |
| 670 | | // On `watch:rtl`, automatically updates the `rtlcss:dynamic` configuration. |
| 671 | | grunt.event.on('watch', function( action, filepath, target ) { |
| 672 | | if ( target !== 'all' && target !== 'rtl' ) { |
| | 670 | /* |
| | 671 | * Automatically updates the `:dynamic` configurations |
| | 672 | * so that only the changed files are updated. |
| | 673 | */ |
| | 674 | grunt.event.on( 'watch', function( action, filepath, target ) { |
| | 675 | var src; |
| | 676 | |
| | 677 | if ( [ 'all', 'rtl', 'browserify' ].indexOf( target ) === -1 ) { |
| 676 | | var relativePath = path.relative( SOURCE_DIR, filepath ), |
| 677 | | cleanSrc = ( action === 'deleted' ) ? [relativePath] : [], |
| 678 | | copySrc = ( action === 'deleted' ) ? [] : [relativePath]; |
| 679 | | |
| 680 | | grunt.config(['clean', 'dynamic', 'src'], cleanSrc); |
| 681 | | grunt.config(['copy', 'dynamic', 'src'], copySrc); |
| 682 | | grunt.config(['rtlcss', 'dynamic', 'src'], copySrc); |
| 683 | | }); |
| | 681 | src = [ path.relative( SOURCE_DIR, filepath ) ]; |
| | 682 | |
| | 683 | if ( action === 'deleted' ) { |
| | 684 | grunt.config( [ 'clean', 'dynamic', 'src' ], src ); |
| | 685 | } else { |
| | 686 | grunt.config( [ 'copy', 'dynamic', 'src' ], src ); |
| | 687 | |
| | 688 | if ( target === 'rtl' ) { |
| | 689 | grunt.config( [ 'rtlcss', 'dynamic', 'src' ], src ); |
| | 690 | } |
| | 691 | } |
| | 692 | } ); |