2014-05-23 16:45:51 +00:00
|
|
|
var fs = require( "fs" ),
|
2014-07-17 16:02:59 +00:00
|
|
|
npm = require( "npm" ),
|
2014-06-10 19:32:25 +00:00
|
|
|
sizzleLoc = __dirname + "/../external/sizzle/dist/sizzle.js",
|
2014-12-17 16:17:41 +00:00
|
|
|
rversion = /Engine v(\d+\.\d+\.\d+(?:-[-\.\d\w]+)?)/;
|
2014-05-23 16:45:51 +00:00
|
|
|
|
2014-07-17 16:02:59 +00:00
|
|
|
require( "colors" );
|
|
|
|
|
2014-05-23 16:45:51 +00:00
|
|
|
/**
|
2014-07-17 16:02:59 +00:00
|
|
|
* Retrieve the latest tag of Sizzle from npm
|
2014-05-23 16:45:51 +00:00
|
|
|
* @param {Function(string)} callback
|
|
|
|
*/
|
|
|
|
function getLatestSizzle( callback ) {
|
2014-07-17 16:02:59 +00:00
|
|
|
npm.load(function( err, npm ) {
|
|
|
|
if ( err ) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
npm.commands.info( [ "sizzle", "version" ], function( err, info ) {
|
|
|
|
if ( err ) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
callback( Object.keys( info )[ 0 ] );
|
|
|
|
});
|
|
|
|
});
|
2014-05-23 16:45:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ensure the /src folder has the latest tag of Sizzle
|
|
|
|
* @param {Object} Release
|
|
|
|
* @param {Function} callback
|
|
|
|
*/
|
|
|
|
function ensureSizzle( Release, callback ) {
|
|
|
|
console.log();
|
|
|
|
console.log( "Checking Sizzle version..." );
|
|
|
|
getLatestSizzle(function( latest ) {
|
|
|
|
var match = rversion.exec( fs.readFileSync( sizzleLoc, "utf8" ) ),
|
|
|
|
version = match ? match[ 1 ] : "Not Found";
|
|
|
|
|
|
|
|
if ( version !== latest ) {
|
|
|
|
console.log(
|
|
|
|
"The Sizzle version in the src folder (" + version.red +
|
|
|
|
") is not the latest tag (" + latest.green + ")."
|
|
|
|
);
|
|
|
|
Release.confirm( callback );
|
|
|
|
} else {
|
|
|
|
console.log( "Sizzle is latest (" + latest.green + ")" );
|
|
|
|
callback();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = ensureSizzle;
|