Release: drop the need for npm as a local dependency

- Not meant to be used like that anymore
This commit is contained in:
Timmy Willison 2021-03-01 17:41:18 -05:00
parent a21a4b2de7
commit 8b50fbe75d
No known key found for this signature in database
GPG Key ID: B1D1D9907F95E829
2 changed files with 16 additions and 36 deletions

View File

@ -90,6 +90,5 @@ module.exports.dependencies = [
"archiver@5.2.0", "archiver@5.2.0",
"shelljs@0.8.4", "shelljs@0.8.4",
"inquirer@8.0.0", "inquirer@8.0.0",
"npm@7.6.0",
"chalk@4.1.0" "chalk@4.1.0"
]; ];

View File

@ -1,29 +1,10 @@
"use strict"; "use strict";
var fs = require( "fs" ), var fs = require( "fs" ),
npm = require( "npm" ),
chalk = require( "chalk" ), chalk = require( "chalk" ),
sizzleLoc = __dirname + "/../../external/sizzle/dist/sizzle.js", sizzleLoc = __dirname + "/../../external/sizzle/dist/sizzle.js",
rversion = /Engine v(\d+\.\d+\.\d+(?:-[-\.\d\w]+)?)/; 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 * Ensure the /src folder has the latest tag of Sizzle
* @param {Object} Release * @param {Object} Release
@ -32,23 +13,23 @@ function getLatestSizzle( callback ) {
function ensureSizzle( Release, callback ) { function ensureSizzle( Release, callback ) {
console.log(); console.log();
console.log( "Checking Sizzle version..." ); console.log( "Checking Sizzle version..." );
getLatestSizzle( function( latest ) { var match = rversion.exec( fs.readFileSync( sizzleLoc, "utf8" ) ),
var match = rversion.exec( fs.readFileSync( sizzleLoc, "utf8" ) ), version = match ? match[ 1 ] : "Not Found",
version = match ? match[ 1 ] : "Not Found"; latest = Release.exec( {
command: "npm info sizzle version",
silent: true
} );
if ( version !== latest ) { if ( version !== latest ) {
console.log(
// colors is inherited from jquery-release "The Sizzle version in the src folder (" + chalk.red( version ) +
console.log( ") is not the latest tag (" + chalk.green( latest ) + ")."
"The Sizzle version in the src folder (" + chalk.red( version ) + );
") is not the latest tag (" + chalk.green( latest ) + ")." Release.confirm( callback );
); } else {
Release.confirm( callback ); console.log( "Sizzle is latest (" + chalk.green( latest ) + ")" );
} else { callback();
console.log( "Sizzle is latest (" + chalk.green( latest ) + ")" ); }
callback();
}
} );
} }
module.exports = ensureSizzle; module.exports = ensureSizzle;