@@ -10,18 +10,19 @@ var debug = false,
1010var fs = require ( "fs" ) ,
1111 child = require ( "child_process" ) ,
1212 path = require ( "path" ) ,
13- which = require ( ' which' ) . sync ;
13+ which = require ( " which" ) . sync ;
1414
1515var releaseVersion ,
1616 nextVersion ,
1717 finalFiles ,
1818 isBeta ,
1919 pkg ,
20+ branch ,
2021
2122 scpURL = "jqadmin@code.origin.jquery.com:/var/www/html/code.jquery.com/" ,
2223 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 = "git@github.com:jquery/jquery.git ",
2526
2627 // Windows needs the .cmd version but will find the non-.cmd
2728 // On Windows, ensure the HOME environment variable is set
@@ -62,18 +63,18 @@ function initialize( next ) {
6263 // First arg should be the version number being released
6364 var newver , oldver ,
6465 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 ) || { } ,
6667 major = version [ 1 ] ,
6768 minor = version [ 2 ] ,
6869 patch = version [ 3 ] ,
6970 xbeta = version [ 4 ] ;
7071
71-
72- releaseVersion = process . argv [ 2 ] ;
72+ branch = process . argv [ 2 ] ;
73+ releaseVersion = process . argv [ 3 ] ;
7374 isBeta = ! ! xbeta ;
7475
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" ) ;
7778 }
7879 if ( xbeta === "pre" ) {
7980 die ( "Cannot release a 'pre' version!" ) ;
@@ -95,7 +96,11 @@ function initialize( next ) {
9596 next ( ) ;
9697}
9798function 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+ }
99104 if ( / C h a n g e s t o b e c o m m i t t e d / i. test ( stdout ) ) {
100105 die ( "Please commit changed files before attemping to push a release." ) ;
101106 }
@@ -107,12 +112,12 @@ function checkGitStatus( next ) {
107112}
108113function tagReleaseVersion ( next ) {
109114 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 ) ;
112117 } ) ;
113118}
114119function gruntBuild ( next ) {
115- exec ( gruntCmd , next ) ;
120+ exec ( gruntCmd , [ ] , next ) ;
116121}
117122function makeReleaseCopies ( next ) {
118123 finalFiles = { } ;
@@ -130,25 +135,25 @@ function makeReleaseCopies( next ) {
130135}
131136function setNextVersion ( next ) {
132137 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 ) ;
134139}
135140function uploadToCDN ( next ) {
136141 var cmds = [ ] ;
137142
138143 Object . keys ( finalFiles ) . forEach ( function ( name ) {
139144 cmds . push ( function ( x ) {
140- exec ( "scp " + name + " " + scpURL , x , skipRemote ) ;
145+ exec ( "scp" , [ name , scpURL ] , x , skipRemote ) ;
141146 } ) ;
142147 cmds . push ( function ( x ) {
143- exec ( "curl '" + cdnURL + name + "?reload'" , x , skipRemote ) ;
148+ exec ( "curl" , [ cdnURL + name + "?reload" ] , x , skipRemote ) ;
144149 } ) ;
145150 } ) ;
146151 cmds . push ( next ) ;
147152
148153 steps . apply ( this , cmds ) ;
149154}
150155function pushToGithub ( next ) {
151- exec ( " git push --tags " + repoURL + " " + branch , next , skipRemote ) ;
156+ git ( [ " push" , " --tags" , repoURL , branch ] , next , skipRemote ) ;
152157}
153158
154159//==============================
@@ -174,18 +179,23 @@ function copy( oldFile, newFile ) {
174179 fs . writeFileSync ( newFile , fs . readFileSync ( oldFile , "utf8" ) ) ;
175180 }
176181}
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 ) {
178186 if ( debug || skip ) {
179- console . log ( "# " + cmd ) ;
187+ console . log ( "# " + cmd + " " + args . join ( " " ) ) ;
180188 fn ( ) ;
181189 } 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 ( ) ;
186197 }
187- fn ( ) ;
188- } ) ;
198+ ) ;
189199 }
190200}
191201function die ( msg ) {
0 commit comments