Skip to content

Commit 0645ac4

Browse files
committed
Build: Replace @Version in release tags
Fixes #10006 Closes jquerygh-1239
1 parent d1a6aed commit 0645ac4

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed

build/release.js

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,38 @@
11
module.exports = function( Release ) {
22

33
var shell = require( "shelljs" ),
4-
path = require( "path" );
4+
path = require( "path" ),
5+
fs = require( "fs" );
6+
7+
function replaceAtVersion() {
8+
console.log( "Replacing @VERSION..." );
9+
var matches = [];
10+
11+
function recurse( folder ) {
12+
fs.readdirSync( folder ).forEach(function( fileName ) {
13+
var content,
14+
fullPath = folder + "/" + fileName;
15+
if ( fs.statSync( fullPath ).isDirectory() ) {
16+
recurse( fullPath );
17+
return;
18+
}
19+
content = fs.readFileSync( fullPath, {
20+
encoding: "utf-8"
21+
});
22+
if ( !/@VERSION/.test( content ) ) {
23+
return;
24+
}
25+
matches.push( fullPath );
26+
fs.writeFileSync( fullPath, content.replace( /@VERSION/g, Release.newVersion ) );
27+
});
28+
}
29+
30+
[ "ui", "themes" ].forEach( recurse );
31+
32+
console.log( "Replaced @VERSION in " + matches.length + " files." );
33+
34+
return matches;
35+
}
536

637
function buildCDNPackage( callback ) {
738
console.log( "Building CDN package" );
@@ -34,7 +65,7 @@ Release.define({
3465
"}</script>\n\nReleased on " + monthNames[ now.getMonth() ] + " " + now.getDate() + ", " + now.getFullYear() + "\n\n";
3566
},
3667
generateArtifacts: function( fn ) {
37-
var manifestFiles;
68+
var files;
3869
function copyCdnFiles() {
3970
var zipFile = shell.ls( "../jquery*-cdn.zip" )[ 0 ],
4071
tmpFolder = "../tmp-zip-output",
@@ -50,11 +81,11 @@ Release.define({
5081
shell.mkdir( "-p", "dist/cdn" );
5182
shell.cp( tmpFolder + "/jquery-ui*.js", "dist/cdn" );
5283
shell.cp( "-r", tmpFolder + "/themes", "dist/cdn" );
53-
fn( manifestFiles );
84+
fn( files );
5485
}
5586

5687
Release.exec( "grunt manifest" );
57-
manifestFiles = shell.ls( "*.jquery.json" );
88+
files = shell.ls( "*.jquery.json" ).concat( replaceAtVersion() );
5889
buildCDNPackage( copyCdnFiles );
5990
}
6091
});

0 commit comments

Comments
 (0)