Skip to content

Commit bddd100

Browse files
committed
Update the build script so it runs on Windows.
1 parent 24db734 commit bddd100

File tree

1 file changed

+45
-30
lines changed

1 file changed

+45
-30
lines changed

build/release.js

+45-30
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ var debug = false,
99

1010
var fs = require("fs"),
1111
child = require("child_process"),
12-
path = require("path"),
13-
which = require('which').sync;
12+
path = require("path");
1413

1514
var releaseVersion,
1615
nextVersion,
1716
finalFiles,
1817
isBeta,
1918
pkg,
19+
branch,
2020

2121
scpURL = "jqadmin@code.origin.jquery.com:/var/www/html/code.jquery.com/",
2222
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",
2525

2626
// Windows needs the .cmd version but will find the non-.cmd
2727
// On Windows, ensure the HOME environment variable is set
@@ -62,18 +62,18 @@ function initialize( next ) {
6262
// First arg should be the version number being released
6363
var newver, oldver,
6464
rversion = /^(\d)\.(\d+)\.(\d)((?:a|b|rc)\d|pre)?$/,
65-
version = ( process.argv[2] || "" ).toLowerCase().match( rversion ) || {},
65+
version = ( process.argv[3] || "" ).toLowerCase().match( rversion ) || {},
6666
major = version[1],
6767
minor = version[2],
6868
patch = version[3],
6969
xbeta = version[4];
7070

71-
72-
releaseVersion = process.argv[2];
71+
branch = process.argv[2];
72+
releaseVersion = process.argv[3];
7373
isBeta = !!xbeta;
7474

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" );
7777
}
7878
if ( xbeta === "pre" ) {
7979
die( "Cannot release a 'pre' version!" );
@@ -95,7 +95,11 @@ function initialize( next ) {
9595
next();
9696
}
9797
function checkGitStatus( next ) {
98-
exec( "git status", function( error, stdout, stderr ) {
98+
git( [ "status" ], function( error, stdout, stderr ) {
99+
var onBranch = ((stdout||"").match( /On branch (\S+)/ ) || [])[1];
100+
if ( onBranch !== branch ) {
101+
die( "Branches don't match: Wanted " + branch + ", got " + onBranch );
102+
}
99103
if ( /Changes to be committed/i.test( stdout ) ) {
100104
die( "Please commit changed files before attemping to push a release." );
101105
}
@@ -107,12 +111,18 @@ function checkGitStatus( next ) {
107111
}
108112
function tagReleaseVersion( next ) {
109113
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);
113117
}
114118
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);
116126
}
117127
function makeReleaseCopies( next ) {
118128
finalFiles = {};
@@ -130,25 +140,25 @@ function makeReleaseCopies( next ) {
130140
}
131141
function setNextVersion( next ) {
132142
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 );
134144
}
135145
function uploadToCDN( next ) {
136146
var cmds = [];
137147

138148
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 );
141151
});
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 );
144154
});
145155
});
146156
cmds.push( next );
147157

148158
steps.apply( this, cmds );
149159
}
150160
function pushToGithub( next ) {
151-
exec("git push --tags "+ repoURL + " " + branch, next, skipRemote );
161+
git( [ "push", "--tags", repoURL, branch ], next, debug || skipRemote );
152162
}
153163

154164
//==============================
@@ -174,18 +184,23 @@ function copy( oldFile, newFile ) {
174184
fs.writeFileSync( newFile, fs.readFileSync( oldFile, "utf8" ) );
175185
}
176186
}
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( "", "", "" );
181194
} 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 );
186202
}
187-
fn();
188-
});
203+
);
189204
}
190205
}
191206
function die( msg ) {

0 commit comments

Comments
 (0)