1
1
module . exports = function ( Release ) {
2
2
3
3
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 ( ! / @ V E R S I O N / . test ( content ) ) {
23
+ return ;
24
+ }
25
+ matches . push ( fullPath ) ;
26
+ fs . writeFileSync ( fullPath , content . replace ( / @ V E R S I O N / 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
+ }
5
36
6
37
function buildCDNPackage ( callback ) {
7
38
console . log ( "Building CDN package" ) ;
@@ -34,7 +65,7 @@ Release.define({
34
65
"}</script>\n\nReleased on " + monthNames [ now . getMonth ( ) ] + " " + now . getDate ( ) + ", " + now . getFullYear ( ) + "\n\n" ;
35
66
} ,
36
67
generateArtifacts : function ( fn ) {
37
- var manifestFiles ;
68
+ var files ;
38
69
function copyCdnFiles ( ) {
39
70
var zipFile = shell . ls ( "../jquery*-cdn.zip" ) [ 0 ] ,
40
71
tmpFolder = "../tmp-zip-output" ,
@@ -50,11 +81,11 @@ Release.define({
50
81
shell . mkdir ( "-p" , "dist/cdn" ) ;
51
82
shell . cp ( tmpFolder + "/jquery-ui*.js" , "dist/cdn" ) ;
52
83
shell . cp ( "-r" , tmpFolder + "/themes" , "dist/cdn" ) ;
53
- fn ( manifestFiles ) ;
84
+ fn ( files ) ;
54
85
}
55
86
56
87
Release . exec ( "grunt manifest" ) ;
57
- manifestFiles = shell . ls ( "*.jquery.json" ) ;
88
+ files = shell . ls ( "*.jquery.json" ) . concat ( replaceAtVersion ( ) ) ;
58
89
buildCDNPackage ( copyCdnFiles ) ;
59
90
}
60
91
} ) ;
0 commit comments