@@ -9,19 +9,19 @@ var debug = false,
9
9
10
10
var fs = require ( "fs" ) ,
11
11
child = require ( "child_process" ) ,
12
- path = require ( "path" ) ,
13
- which = require ( 'which' ) . sync ;
12
+ path = require ( "path" ) ;
14
13
15
14
var releaseVersion ,
16
15
nextVersion ,
17
16
finalFiles ,
18
17
isBeta ,
19
18
pkg ,
19
+ branch ,
20
20
21
21
scpURL = "jqadmin@code.origin.jquery.com:/var/www/html/code.jquery.com/" ,
22
22
cdnURL = "http://code.origin.jquery.com/" ,
23
- repoURL = "git://github.com/jquery /jquery.git" ,
24
- branch = "master " ,
23
+ repoURL = "git://github.com/dmethvin /jquery.git" ,
24
+ //repoURL = "git://github.com/jquery/jquery.git ",
25
25
26
26
// Windows needs the .cmd version but will find the non-.cmd
27
27
// On Windows, ensure the HOME environment variable is set
@@ -62,18 +62,18 @@ function initialize( next ) {
62
62
// First arg should be the version number being released
63
63
var newver , oldver ,
64
64
rversion = / ^ ( \d ) \. ( \d + ) \. ( \d ) ( (?: a | b | r c ) \d | p r e ) ? $ / ,
65
- version = ( process . argv [ 2 ] || "" ) . toLowerCase ( ) . match ( rversion ) || { } ,
65
+ version = ( process . argv [ 3 ] || "" ) . toLowerCase ( ) . match ( rversion ) || { } ,
66
66
major = version [ 1 ] ,
67
67
minor = version [ 2 ] ,
68
68
patch = version [ 3 ] ,
69
69
xbeta = version [ 4 ] ;
70
70
71
-
72
- releaseVersion = process . argv [ 2 ] ;
71
+ branch = process . argv [ 2 ] ;
72
+ releaseVersion = process . argv [ 3 ] ;
73
73
isBeta = ! ! xbeta ;
74
74
75
- if ( ! major || ! minor || ! patch ) {
76
- die ( "Usage: " + process . argv [ 1 ] + " releaseVersion" ) ;
75
+ if ( ! branch || ! major || ! minor || ! patch ) {
76
+ die ( "Usage: " + process . argv [ 1 ] + " branch releaseVersion" ) ;
77
77
}
78
78
if ( xbeta === "pre" ) {
79
79
die ( "Cannot release a 'pre' version!" ) ;
@@ -95,7 +95,11 @@ function initialize( next ) {
95
95
next ( ) ;
96
96
}
97
97
function checkGitStatus ( next ) {
98
- exec ( "git status" , function ( error , stdout , stderr ) {
98
+ git ( [ "status" ] , function ( error , stdout , stderr ) {
99
+ var onBranch = ( ( stdout || "" ) . match ( / O n b r a n c h ( \S + ) / ) || [ ] ) [ 1 ] ;
100
+ if ( onBranch !== branch ) {
101
+ die ( "Branches don't match: Wanted " + branch + ", got " + onBranch ) ;
102
+ }
99
103
if ( / C h a n g e s t o b e c o m m i t t e d / i. test ( stdout ) ) {
100
104
die ( "Please commit changed files before attemping to push a release." ) ;
101
105
}
@@ -107,12 +111,18 @@ function checkGitStatus( next ) {
107
111
}
108
112
function tagReleaseVersion ( next ) {
109
113
updatePackageVersion ( releaseVersion ) ;
110
- exec ( 'git commit -a -m "Tagging the ' + releaseVersion + ' release."' , function ( ) {
111
- exec ( "git tag " + releaseVersion , next ) ;
112
- } ) ;
114
+ git ( [ " commit" , "-a" , "-m" , "Tagging the " + releaseVersion + " release." ] , function ( ) {
115
+ git ( [ " tag" , releaseVersion ] , next , debug ) ;
116
+ } , debug ) ;
113
117
}
114
118
function gruntBuild ( next ) {
115
- exec ( gruntCmd , next ) ;
119
+ exec ( gruntCmd , [ ] , function ( error , stdout ) {
120
+ if ( error ) {
121
+ die ( error + stderr ) ;
122
+ }
123
+ console . log ( stdout ) ;
124
+ next ( ) ;
125
+ } , debug ) ;
116
126
}
117
127
function makeReleaseCopies ( next ) {
118
128
finalFiles = { } ;
@@ -130,25 +140,25 @@ function makeReleaseCopies( next ) {
130
140
}
131
141
function setNextVersion ( next ) {
132
142
updatePackageVersion ( nextVersion ) ;
133
- exec ( 'git commit -a -m "Updating the source version to ' + nextVersion + '"' , next ) ;
143
+ git ( [ " commit" , "-a" , "-m" , "Updating the source version to " + nextVersion ] , next , debug ) ;
134
144
}
135
145
function uploadToCDN ( next ) {
136
146
var cmds = [ ] ;
137
147
138
148
Object . keys ( finalFiles ) . forEach ( function ( name ) {
139
- cmds . push ( function ( x ) {
140
- exec ( "scp " + name + " " + scpURL , x , skipRemote ) ;
149
+ cmds . push ( function ( nxt ) {
150
+ exec ( "scp" , [ name , scpURL ] , nxt , debug || skipRemote ) ;
141
151
} ) ;
142
- cmds . push ( function ( x ) {
143
- exec ( "curl '" + cdnURL + name + "?reload'" , x , skipRemote ) ;
152
+ cmds . push ( function ( nxt ) {
153
+ exec ( "curl" , [ cdnURL + name + "?reload" ] , nxt , debug || skipRemote ) ;
144
154
} ) ;
145
155
} ) ;
146
156
cmds . push ( next ) ;
147
157
148
158
steps . apply ( this , cmds ) ;
149
159
}
150
160
function pushToGithub ( next ) {
151
- exec ( " git push --tags " + repoURL + " " + branch , next , skipRemote ) ;
161
+ git ( [ " push" , " --tags" , repoURL , branch ] , next , debug || skipRemote ) ;
152
162
}
153
163
154
164
//==============================
@@ -174,18 +184,23 @@ function copy( oldFile, newFile ) {
174
184
fs . writeFileSync ( newFile , fs . readFileSync ( oldFile , "utf8" ) ) ;
175
185
}
176
186
}
177
- function exec ( cmd , fn , skip ) {
178
- if ( debug || skip ) {
179
- console . log ( "# " + cmd ) ;
180
- fn ( ) ;
187
+ function git ( args , fn , skip ) {
188
+ exec ( "git" , args , fn , skip ) ;
189
+ }
190
+ function exec ( cmd , args , fn , skip ) {
191
+ if ( skip ) {
192
+ console . log ( "# " + cmd + " " + args . join ( " " ) ) ;
193
+ fn ( "" , "" , "" ) ;
181
194
} else {
182
- console . log ( cmd ) ;
183
- child . exec ( cmd , { env : process . env } , function ( err , stdout , stderr ) {
184
- if ( err ) {
185
- die ( stderr || stdout || err ) ;
195
+ console . log ( cmd + " " + args . join ( " " ) ) ;
196
+ child . execFile ( cmd , args , { env : process . env } ,
197
+ function ( err , stdout , stderr ) {
198
+ if ( err ) {
199
+ die ( stderr || stdout || err ) ;
200
+ }
201
+ fn . apply ( this , arguments ) ;
186
202
}
187
- fn ( ) ;
188
- } ) ;
203
+ ) ;
189
204
}
190
205
}
191
206
function die ( msg ) {
0 commit comments