Release: add support for md5 sums in windows

Close gh-5219
This commit is contained in:
Timmy Willison 2023-03-09 15:19:07 -05:00 committed by GitHub
parent 68aa2ef757
commit f088c36631
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@ var
fs = require( "fs" ), fs = require( "fs" ),
shell = require( "shelljs" ), shell = require( "shelljs" ),
path = require( "path" ), path = require( "path" ),
os = require( "os" ),
cdnFolder = "dist/cdn", cdnFolder = "dist/cdn",
@ -68,12 +69,13 @@ function makeArchives( Release, callback ) {
console.log( "Creating production archive for " + cdn ); console.log( "Creating production archive for " + cdn );
var sum, var i, sum, result,
archiver = require( "archiver" )( "zip" ), archiver = require( "archiver" )( "zip" ),
md5file = cdnFolder + "/" + cdn + "-md5.txt", md5file = cdnFolder + "/" + cdn + "-md5.txt",
output = fs.createWriteStream( output = fs.createWriteStream(
cdnFolder + "/" + cdn + "-jquery-" + Release.newVersion + ".zip" cdnFolder + "/" + cdn + "-jquery-" + Release.newVersion + ".zip"
), ),
rmd5 = /[a-f0-9]{32}/,
rver = /VER/; rver = /VER/;
output.on( "close", callback ); output.on( "close", callback );
@ -89,7 +91,18 @@ function makeArchives( Release, callback ) {
item.replace( rver, Release.newVersion ); item.replace( rver, Release.newVersion );
} ); } );
sum = Release.exec( "md5 -r " + files.join( " " ), "Error retrieving md5sum" ); if ( os.platform() === "win32" ) {
sum = [];
for ( i = 0; i < files.length; i++ ) {
result = Release.exec(
"certutil -hashfile " + files[ i ] + " MD5", "Error retrieving md5sum"
);
sum.push( rmd5.exec( result )[ 0 ] + " " + files[ i ] );
}
sum = sum.join( "\n" );
} else {
sum = Release.exec( "md5 -r " + files.join( " " ), "Error retrieving md5sum" );
}
fs.writeFileSync( md5file, sum ); fs.writeFileSync( md5file, sum );
files.push( md5file ); files.push( md5file );