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