Skip to content

Commit 7475763

Browse files
committed
Grunt: Replace all instances of @Version during copy. Fixes #8261 - Build: @Version replacement incomplete.
1 parent d5cde20 commit 7475763

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

grunt.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,16 @@ grunt.initConfig({
361361

362362
grunt.registerMultiTask( "copy", "Copy files to destination folder and replace @VERSION with pkg.version", function() {
363363
function replaceVersion( source ) {
364-
return source.replace( "@VERSION", grunt.config( "pkg.version" ) );
364+
return source.replace( /@VERSION/g, grunt.config( "pkg.version" ) );
365+
}
366+
function copyFile( src, dest ) {
367+
if ( /(js|css)$/.test( src ) ) {
368+
grunt.file.copy( src, dest, {
369+
process: replaceVersion
370+
});
371+
} else {
372+
grunt.file.copy( src, dest );
373+
}
365374
}
366375
var files = grunt.file.expandFiles( this.file.src ),
367376
target = this.file.dest + "/",
@@ -373,18 +382,12 @@ grunt.registerMultiTask( "copy", "Copy files to destination folder and replace @
373382
}
374383
files.forEach(function( fileName ) {
375384
var targetFile = strip ? fileName.replace( strip, "" ) : fileName;
376-
if ( /(js|css)$/.test( fileName ) ) {
377-
grunt.file.copy( fileName, target + targetFile, {
378-
process: replaceVersion
379-
});
380-
} else {
381-
grunt.file.copy( fileName, target + targetFile );
382-
}
385+
copyFile( fileName, target + targetFile );
383386
});
384387
grunt.log.writeln( "Copied " + files.length + " files." );
385388
for ( fileName in this.data.renames ) {
386389
renameCount += 1;
387-
grunt.file.copy( fileName, target + grunt.template.process( this.data.renames[ fileName ], grunt.config() ) );
390+
copyFile( fileName, target + grunt.template.process( this.data.renames[ fileName ], grunt.config() ) );
388391
}
389392
if ( renameCount ) {
390393
grunt.log.writeln( "Renamed " + renameCount + " files." );

0 commit comments

Comments
 (0)