@@ -361,7 +361,16 @@ grunt.initConfig({
361361
362362grunt . 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 ( / @ V E R S I O N / g, grunt . config ( "pkg.version" ) ) ;
365+ }
366+ function copyFile ( src , dest ) {
367+ if ( / ( j s | c s s ) $ / . 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 ( / ( j s | c s s ) $ / . 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