2019-10-08 22:17:55 +00:00
|
|
|
"use strict";
|
|
|
|
|
2014-05-23 16:45:51 +00:00
|
|
|
var fs = require( "fs" ),
|
2014-07-17 16:02:59 +00:00
|
|
|
npm = require( "npm" ),
|
2015-11-12 18:23:53 +00:00
|
|
|
chalk = require( "chalk" ),
|
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-08-16 06:59:58 +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-08-16 06:59:58 +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-08-16 06:59:58 +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-08-16 06:59:58 +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(
|
2015-11-12 18:23:53 +00:00
|
|
|
"The Sizzle version in the src folder (" + chalk.red( version ) +
|
|
|
|
") is not the latest tag (" + chalk.green( latest ) + ")."
|
2014-05-23 16:45:51 +00:00
|
|
|
);
|
|
|
|
Release.confirm( callback );
|
|
|
|
} else {
|
2015-11-12 18:23:53 +00:00
|
|
|
console.log( "Sizzle is latest (" + chalk.green( latest ) + ")" );
|
2014-05-23 16:45:51 +00:00
|
|
|
callback();
|
|
|
|
}
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2014-05-23 16:45:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = ensureSizzle;
|