aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2012-04-18 16:17:21 -0400
committerScott González <scott.gonzalez@gmail.com>2012-04-18 16:17:36 -0400
commit2f4c74c4cec9e44e003b1d2570b259dfaf9f57d9 (patch)
tree317dbae7b0ea143471fb1e2e8a66da92356927ed
parentaec682c9c68946d55856fb21d9124ce418e9285c (diff)
downloadjquery-ui-2f4c74c4cec9e44e003b1d2570b259dfaf9f57d9.tar.gz
jquery-ui-2f4c74c4cec9e44e003b1d2570b259dfaf9f57d9.zip
Grunt: Replace all instances of @VERSION during copy. Fixes #8261 - Build: @VERSION replacement incomplete.
(cherry picked from commit 7475763474ba2dc976136c9374b201a1f6df8a83)
-rw-r--r--grunt.js21
1 files changed, 12 insertions, 9 deletions
diff --git a/grunt.js b/grunt.js
index 9e0b3f5e7..01aef88a2 100644
--- a/grunt.js
+++ b/grunt.js
@@ -332,7 +332,16 @@ grunt.initConfig({
grunt.registerMultiTask( "copy", "Copy files to destination folder and replace @VERSION with pkg.version", function() {
function replaceVersion( source ) {
- return source.replace( "@VERSION", grunt.config( "pkg.version" ) );
+ return source.replace( /@VERSION/g, grunt.config( "pkg.version" ) );
+ }
+ function copyFile( src, dest ) {
+ if ( /(js|css)$/.test( src ) ) {
+ grunt.file.copy( src, dest, {
+ process: replaceVersion
+ });
+ } else {
+ grunt.file.copy( src, dest );
+ }
}
var files = grunt.file.expandFiles( this.file.src );
var target = this.file.dest + "/";
@@ -342,19 +351,13 @@ grunt.registerMultiTask( "copy", "Copy files to destination folder and replace @
}
files.forEach(function( fileName ) {
var targetFile = strip ? fileName.replace( strip, "" ) : fileName;
- if ( /(js|css)$/.test( fileName ) ) {
- grunt.file.copy( fileName, target + targetFile, {
- process: replaceVersion
- });
- } else {
- grunt.file.copy( fileName, target + targetFile );
- }
+ copyFile( fileName, target + targetFile );
});
grunt.log.writeln( "Copied " + files.length + " files." );
var renameCount = 0;
for ( var fileName in this.data.renames ) {
renameCount += 1;
- grunt.file.copy( fileName, target + grunt.template.process( this.data.renames[ fileName ], grunt.config() ) );
+ copyFile( fileName, target + grunt.template.process( this.data.renames[ fileName ], grunt.config() ) );
}
if ( renameCount ) {
grunt.log.writeln( "Renamed " + renameCount + " files." );