mirror of
https://github.com/jquery/jquery.git
synced 2024-12-09 08:04:24 +00:00
ac2da4e6b9
So far, only browser-based JS files were required to be in strict mode (in the
function form). This commit adds such a requirement to Node.js scripts where
the global form is preferred. All Node.js scripts in sloppy mode were
converted to strict mode.
Closes gh-4499
(cherry picked from commit bbad821c39
)
55 lines
1.3 KiB
JavaScript
55 lines
1.3 KiB
JavaScript
"use strict";
|
|
|
|
var fs = require( "fs" ),
|
|
npm = require( "npm" ),
|
|
chalk = require( "chalk" ),
|
|
sizzleLoc = __dirname + "/../../external/sizzle/dist/sizzle.js",
|
|
rversion = /Engine v(\d+\.\d+\.\d+(?:-[-\.\d\w]+)?)/;
|
|
|
|
/**
|
|
* Retrieve the latest tag of Sizzle from npm
|
|
* @param {Function(string)} callback
|
|
*/
|
|
function getLatestSizzle( callback ) {
|
|
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 ] );
|
|
} );
|
|
} );
|
|
}
|
|
|
|
/**
|
|
* 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 ) {
|
|
|
|
// colors is inherited from jquery-release
|
|
console.log(
|
|
"The Sizzle version in the src folder (" + chalk.red( version ) +
|
|
") is not the latest tag (" + chalk.green( latest ) + ")."
|
|
);
|
|
Release.confirm( callback );
|
|
} else {
|
|
console.log( "Sizzle is latest (" + chalk.green( latest ) + ")" );
|
|
callback();
|
|
}
|
|
} );
|
|
}
|
|
|
|
module.exports = ensureSizzle;
|