Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita7fa303

Browse files
authored
Build: sort branches in compare_size; last run last
Closegh-5333
1 parentcb76307 commita7fa303

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

‎build/tasks/compare_size.mjs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { exec as nodeExec } from "node:child_process";
66
importisCleanWorkingDirfrom"./lib/isCleanWorkingDir.js";
77

88
constVERSION=1;
9+
constlastRunBranch=" last run";
910

1011
constgzip=promisify(zlib.gzip);
1112
constexec=promisify(nodeExec);
@@ -39,7 +40,7 @@ async function getCache( loc ) {
3940
return{};
4041
}
4142

42-
constlastRun=cache[" last run"];
43+
constlastRun=cache[lastRunBranch];
4344
if(!lastRun||!lastRun.meta||lastRun.meta.version!==VERSION){
4445
console.log("Compare cache version mismatch. Rewriting...");
4546
return{};
@@ -73,6 +74,22 @@ function compareSizes( existing, current, padLength ) {
7374
returnchalk.green(`${delta}`.padStart(padLength));
7475
}
7576

77+
functionsortBranches(a,b){
78+
if(a===lastRunBranch){
79+
return1;
80+
}
81+
if(b===lastRunBranch){
82+
return-1;
83+
}
84+
if(a<b){
85+
return-1;
86+
}
87+
if(a>b){
88+
return1;
89+
}
90+
return0;
91+
}
92+
7693
exportasyncfunctioncompareSize({ cache=".sizecache.json", files}={}){
7794
if(!files||!files.length){
7895
thrownewError("No files specified");
@@ -116,7 +133,7 @@ export async function compareSize( { cache = ".sizecache.json", files } = {} ) {
116133
return`${rawSize}${gzSize}${result.filename}`;
117134
});
118135

119-
constcomparisons=Object.keys(sizeCache).map(function(branch){
136+
constcomparisons=Object.keys(sizeCache).sort(sortBranches).map(function(branch){
120137
constmeta=sizeCache[branch].meta||{};
121138
constcommit=meta.commit;
122139

@@ -153,7 +170,7 @@ export async function compareSize( { cache = ".sizecache.json", files } = {} ) {
153170

154171
// Always save the last run
155172
// Save version under last run
156-
sizeCache[" last run"]={
173+
sizeCache[lastRunBranch]={
157174
meta:{version:VERSION},
158175
files:cacheResults(results)
159176
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp