mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-10-05 01:44:18 +00:00
Grunt: Replace all instances of @VERSION during copy. Fixes #8261 - Build: @VERSION replacement incomplete.
This commit is contained in:
parent
d5cde2043b
commit
7475763474
21
grunt.js
21
grunt.js
@ -361,7 +361,16 @@ grunt.initConfig({
|
|||||||
|
|
||||||
grunt.registerMultiTask( "copy", "Copy files to destination folder and replace @VERSION with pkg.version", function() {
|
grunt.registerMultiTask( "copy", "Copy files to destination folder and replace @VERSION with pkg.version", function() {
|
||||||
function replaceVersion( source ) {
|
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 files = grunt.file.expandFiles( this.file.src ),
|
||||||
target = this.file.dest + "/",
|
target = this.file.dest + "/",
|
||||||
@ -373,18 +382,12 @@ grunt.registerMultiTask( "copy", "Copy files to destination folder and replace @
|
|||||||
}
|
}
|
||||||
files.forEach(function( fileName ) {
|
files.forEach(function( fileName ) {
|
||||||
var targetFile = strip ? fileName.replace( strip, "" ) : fileName;
|
var targetFile = strip ? fileName.replace( strip, "" ) : fileName;
|
||||||
if ( /(js|css)$/.test( fileName ) ) {
|
copyFile( fileName, target + targetFile );
|
||||||
grunt.file.copy( fileName, target + targetFile, {
|
|
||||||
process: replaceVersion
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
grunt.file.copy( fileName, target + targetFile );
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
grunt.log.writeln( "Copied " + files.length + " files." );
|
grunt.log.writeln( "Copied " + files.length + " files." );
|
||||||
for ( fileName in this.data.renames ) {
|
for ( fileName in this.data.renames ) {
|
||||||
renameCount += 1;
|
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 ) {
|
if ( renameCount ) {
|
||||||
grunt.log.writeln( "Renamed " + renameCount + " files." );
|
grunt.log.writeln( "Renamed " + renameCount + " files." );
|
||||||
|
Loading…
Reference in New Issue
Block a user