mirror of
git://develop.git.wordpress.org/
synced 2025-01-16 20:38:35 +01:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@43327 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
50cd98012e
commit
ccecd58f97
13
Gruntfile.js
13
Gruntfile.js
@ -1355,7 +1355,7 @@ module.exports = function(grunt) {
|
||||
* Automatically updates the `:dynamic` configurations
|
||||
* so that only the changed files are updated.
|
||||
*/
|
||||
grunt.event.on('watch', function( action, filepath, target ) {
|
||||
grunt.event.on( 'watch', function( action, filepath, target ) {
|
||||
var src;
|
||||
|
||||
// Only configure the dynamic tasks based on known targets.
|
||||
@ -1363,6 +1363,9 @@ module.exports = function(grunt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Normalize filepath for Windows.
|
||||
filepath = filepath.replace( /\\/g, '/' );
|
||||
|
||||
// If the target is a file in the restructured js src.
|
||||
if ( target === 'js-enqueues' ) {
|
||||
var files = {};
|
||||
@ -1392,9 +1395,10 @@ module.exports = function(grunt) {
|
||||
grunt.config( [ 'copy', 'admin-js', 'files' ] ),
|
||||
grunt.config( [ 'copy', 'includes-js', 'files' ] )
|
||||
);
|
||||
|
||||
for ( dest in configs ) {
|
||||
// If a file in the mapping matches then set the variables for our dynamic tasks.
|
||||
if ( configs.hasOwnProperty( dest ) && configs[ dest ][0] === './' + filepath ) {
|
||||
if ( dest && configs.hasOwnProperty( dest ) && configs[ dest ][0] === './' + filepath ) {
|
||||
files[ dest ] = configs[ dest ];
|
||||
src = [ path.relative( BUILD_DIR, dest ) ];
|
||||
break;
|
||||
@ -1419,6 +1423,11 @@ module.exports = function(grunt) {
|
||||
src = [ path.relative( SOURCE_DIR, filepath ) ];
|
||||
}
|
||||
|
||||
if ( ! src ) {
|
||||
grunt.warn( 'Failed to determine the destination file.' );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( action === 'deleted' ) {
|
||||
// Clean up only those files that were deleted.
|
||||
grunt.config( [ 'clean', 'dynamic', 'src' ], src );
|
||||
|
Loading…
x
Reference in New Issue
Block a user