@@ -361,7 +361,16 @@ grunt.initConfig({
361
361
362
362
grunt . registerMultiTask ( "copy" , "Copy files to destination folder and replace @VERSION with pkg.version" , function ( ) {
363
363
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
+ }
365
374
}
366
375
var files = grunt . file . expandFiles ( this . file . src ) ,
367
376
target = this . file . dest + "/" ,
@@ -373,18 +382,12 @@ grunt.registerMultiTask( "copy", "Copy files to destination folder and replace @
373
382
}
374
383
files . forEach ( function ( fileName ) {
375
384
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 ) ;
383
386
} ) ;
384
387
grunt . log . writeln ( "Copied " + files . length + " files." ) ;
385
388
for ( fileName in this . data . renames ) {
386
389
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 ( ) ) ) ;
388
391
}
389
392
if ( renameCount ) {
390
393
grunt . log . writeln ( "Renamed " + renameCount + " files." ) ;
0 commit comments