@@ -332,7 +332,16 @@ grunt.initConfig({
332332
333333grunt . registerMultiTask ( "copy" , "Copy files to destination folder and replace @VERSION with pkg.version" , function ( ) {
334334 function replaceVersion ( source ) {
335- return source . replace ( "@VERSION" , grunt . config ( "pkg.version" ) ) ;
335+ return source . replace ( / @ V E R S I O N / g, grunt . config ( "pkg.version" ) ) ;
336+ }
337+ function copyFile ( src , dest ) {
338+ if ( / ( j s | c s s ) $ / . test ( src ) ) {
339+ grunt . file . copy ( src , dest , {
340+ process : replaceVersion
341+ } ) ;
342+ } else {
343+ grunt . file . copy ( src , dest ) ;
344+ }
336345 }
337346 var files = grunt . file . expandFiles ( this . file . src ) ;
338347 var target = this . file . dest + "/" ;
@@ -342,19 +351,13 @@ grunt.registerMultiTask( "copy", "Copy files to destination folder and replace @
342351 }
343352 files . forEach ( function ( fileName ) {
344353 var targetFile = strip ? fileName . replace ( strip , "" ) : fileName ;
345- if ( / ( j s | c s s ) $ / . test ( fileName ) ) {
346- grunt . file . copy ( fileName , target + targetFile , {
347- process : replaceVersion
348- } ) ;
349- } else {
350- grunt . file . copy ( fileName , target + targetFile ) ;
351- }
354+ copyFile ( fileName , target + targetFile ) ;
352355 } ) ;
353356 grunt . log . writeln ( "Copied " + files . length + " files." ) ;
354357 var renameCount = 0 ;
355358 for ( var fileName in this . data . renames ) {
356359 renameCount += 1 ;
357- grunt . file . copy ( fileName , target + grunt . template . process ( this . data . renames [ fileName ] , grunt . config ( ) ) ) ;
360+ copyFile ( fileName , target + grunt . template . process ( this . data . renames [ fileName ] , grunt . config ( ) ) ) ;
358361 }
359362 if ( renameCount ) {
360363 grunt . log . writeln ( "Renamed " + renameCount + " files." ) ;
0 commit comments