Skip to content

Commit

Permalink
build: switch from .min.gz to .zip format.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmethvin committed May 13, 2013
1 parent eaee6ea commit 5e8a5f4
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions build/release.js
Expand Up @@ -10,12 +10,7 @@ var debug = false,
var fs = require("fs"), var fs = require("fs"),
child = require("child_process"), child = require("child_process"),
path = require("path"), path = require("path"),
zlib = require("zlib"); archiver = require("archiver");

var archiver = require("archiver");
var gzipOptions = {
level: 9
};


var releaseVersion, var releaseVersion,
nextVersion, nextVersion,
Expand Down Expand Up @@ -121,7 +116,7 @@ function checkGitStatus( next ) {
git( [ "status" ], function( error, stdout, stderr ) { git( [ "status" ], function( error, stdout, stderr ) {
var onBranch = ((stdout||"").match( /On branch (\S+)/ ) || [])[1]; var onBranch = ((stdout||"").match( /On branch (\S+)/ ) || [])[1];
if ( onBranch !== branch ) { if ( onBranch !== branch ) {
die( "Branches don't match: Wanted " + branch + ", got " + onBranch ); dieIfReal( "Branches don't match: Wanted " + branch + ", got " + onBranch );
} }
if ( /Changes to be committed/i.test( stdout ) ) { if ( /Changes to be committed/i.test( stdout ) ) {
dieIfReal( "Please commit changed files before attemping to push a release." ); dieIfReal( "Please commit changed files before attemping to push a release." );
Expand All @@ -147,7 +142,7 @@ function gruntBuild( next ) {
} }
console.log( stdout ); console.log( stdout );
next(); next();
}, debug); }, false );
} }


function makeReleaseCopies( next ) { function makeReleaseCopies( next ) {
Expand All @@ -168,9 +163,7 @@ function makeReleaseCopies( next ) {
"\"file\":\"" + releaseFile.replace( /\.min\.map/, ".min.js" ) + "\"file\":\"" + releaseFile.replace( /\.min\.map/, ".min.js" ) +
"\",\"sources\":[\"" + releaseFile.replace( /\.min\.map/, ".js" ) + "\"]" ); "\",\"sources\":[\"" + releaseFile.replace( /\.min\.map/, ".js" ) + "\"]" );
console.log( "Modifying map " + builtFile + " to " + releaseFile ); console.log( "Modifying map " + builtFile + " to " + releaseFile );
if ( !debug ) { fs.writeFileSync( "dist/" + releaseFile, text );
fs.writeFileSync( "dist/" + releaseFile, text );
}
} else { } else {
copy( builtFile, "dist/" + releaseFile ); copy( builtFile, "dist/" + releaseFile );
} }
Expand Down Expand Up @@ -243,24 +236,21 @@ function makeArchive( cdn, files, fn ) {


console.log( "Creating production archive for " + cdn ); console.log( "Creating production archive for " + cdn );


var gzipper = zlib.createGzip( gzipOptions ); var archive = archiver( "zip" ),
var output = fs.createWriteStream( "dist/" + cdn + "-jquery-" + releaseVersion + ".tar.gz" ); md5file = "dist/" + cdn + "-md5.txt",

output = fs.createWriteStream( "dist/" + cdn + "-jquery-" + releaseVersion + ".zip" );
var archive = archiver( "tar" );


archive.on( "error", function( err ) { archive.on( "error", function( err ) {
throw err; throw err;
}); });


output.on( "close", fn ); output.on( "close", fn );

archive.pipe( output );
archive.pipe( gzipper ).pipe( output );


files = files.map(function( item ) { files = files.map(function( item ) {
return "dist/" + item.replace( /VER/g, releaseVersion ); return "dist/" + item.replace( /VER/g, releaseVersion );
}); });


var md5file = "dist/" + cdn + "-md5.txt";
exec( "md5sum", files, function( err, stdout, stderr ) { exec( "md5sum", files, function( err, stdout, stderr ) {
fs.writeFileSync( md5file, stdout ); fs.writeFileSync( md5file, stdout );
files.push( md5file ); files.push( md5file );
Expand All @@ -273,9 +263,9 @@ function makeArchive( cdn, files, fn ) {
}, false ); }, false );
} }


function copy( oldFile, newFile ) { function copy( oldFile, newFile, skip ) {
console.log( "Copying " + oldFile + " to " + newFile ); console.log( "Copying " + oldFile + " to " + newFile );
if ( !debug ) { if ( !skip ) {
fs.writeFileSync( newFile, fs.readFileSync( oldFile, "utf8" ) ); fs.writeFileSync( newFile, fs.readFileSync( oldFile, "utf8" ) );
} }
} }
Expand Down

0 comments on commit 5e8a5f4

Please sign in to comment.