mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Build: sort branches in compare_size; last run last
Close gh-5334
This commit is contained in:
parent
ec8802bafe
commit
ce52a5dbb0
@ -6,6 +6,7 @@ import { exec as nodeExec } from "node:child_process";
|
|||||||
import isCleanWorkingDir from "./lib/isCleanWorkingDir.js";
|
import isCleanWorkingDir from "./lib/isCleanWorkingDir.js";
|
||||||
|
|
||||||
const VERSION = 1;
|
const VERSION = 1;
|
||||||
|
const lastRunBranch = " last run";
|
||||||
|
|
||||||
const gzip = promisify( zlib.gzip );
|
const gzip = promisify( zlib.gzip );
|
||||||
const exec = promisify( nodeExec );
|
const exec = promisify( nodeExec );
|
||||||
@ -39,7 +40,7 @@ async function getCache( loc ) {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const lastRun = cache[ " last run" ];
|
const lastRun = cache[ lastRunBranch ];
|
||||||
if ( !lastRun || !lastRun.meta || lastRun.meta.version !== VERSION ) {
|
if ( !lastRun || !lastRun.meta || lastRun.meta.version !== VERSION ) {
|
||||||
console.log( "Compare cache version mismatch. Rewriting..." );
|
console.log( "Compare cache version mismatch. Rewriting..." );
|
||||||
return {};
|
return {};
|
||||||
@ -73,6 +74,22 @@ function compareSizes( existing, current, padLength ) {
|
|||||||
return chalk.green( `${delta}`.padStart( padLength ) );
|
return chalk.green( `${delta}`.padStart( padLength ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sortBranches( a, b ) {
|
||||||
|
if ( a === lastRunBranch ) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if ( b === lastRunBranch ) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if ( a < b ) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if ( a > b ) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
export async function compareSize( { cache = ".sizecache.json", files } = {} ) {
|
export async function compareSize( { cache = ".sizecache.json", files } = {} ) {
|
||||||
if ( !files || !files.length ) {
|
if ( !files || !files.length ) {
|
||||||
throw new Error( "No files specified" );
|
throw new Error( "No files specified" );
|
||||||
@ -116,7 +133,7 @@ export async function compareSize( { cache = ".sizecache.json", files } = {} ) {
|
|||||||
return `${rawSize} ${gzSize} ${result.filename}`;
|
return `${rawSize} ${gzSize} ${result.filename}`;
|
||||||
} );
|
} );
|
||||||
|
|
||||||
const comparisons = Object.keys( sizeCache ).map( function( branch ) {
|
const comparisons = Object.keys( sizeCache ).sort( sortBranches ).map( function( branch ) {
|
||||||
const meta = sizeCache[ branch ].meta || {};
|
const meta = sizeCache[ branch ].meta || {};
|
||||||
const commit = meta.commit;
|
const commit = meta.commit;
|
||||||
|
|
||||||
@ -153,7 +170,7 @@ export async function compareSize( { cache = ".sizecache.json", files } = {} ) {
|
|||||||
|
|
||||||
// Always save the last run
|
// Always save the last run
|
||||||
// Save version under last run
|
// Save version under last run
|
||||||
sizeCache[ " last run" ] = {
|
sizeCache[ lastRunBranch ] = {
|
||||||
meta: { version: VERSION },
|
meta: { version: VERSION },
|
||||||
files: cacheResults( results )
|
files: cacheResults( results )
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user