2014-05-23 16:45:51 +00:00
|
|
|
var fs = require( "fs" ),
|
2014-07-17 16:02:59 +00:00
|
|
|
npm = require( "npm" ),
|
2015-01-28 19:37:29 +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
|
|
|
* Retrieve the latest tag of Sizzle from npm
|
2014-05-23 16:45:51 +00:00
|
|
|
* @param {Function(string)} callback
|
|
|
|
*/
|
|
|
|
function getLatestSizzle( callback ) {
|
2015-09-02 23:52:01 +00:00
|
|
|
npm.load( function( err, npm ) {
|
2014-07-17 16:02:59 +00:00
|
|
|
if ( err ) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
npm.commands.info( [ "sizzle", "version" ], function( err, info ) {
|
|
|
|
if ( err ) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
callback( Object.keys( info )[ 0 ] );
|
2015-09-02 23:52:01 +00:00
|
|
|
} );
|
|
|
|
} );
|
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..." );
|
2015-09-02 23:52:01 +00:00
|
|
|
getLatestSizzle( function( latest ) {
|
2014-05-23 16:45:51 +00:00
|
|
|
var match = rversion.exec( fs.readFileSync( sizzleLoc, "utf8" ) ),
|
|
|
|
version = match ? match[ 1 ] : "Not Found";
|
|
|
|
|
|
|
|
if ( version !== latest ) {
|
2015-09-02 23:52:01 +00:00
|
|
|
|
2015-01-28 19:37:29 +00:00
|
|
|
// colors is inherited from jquery-release
|
2014-05-23 16:45:51 +00:00
|
|
|
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();
|
|
|
|
}
|
2015-09-02 23:52:01 +00:00
|
|
|
} );
|
2014-05-23 16:45:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = ensureSizzle;
|