Skip to content

Commit 7480b25

Browse files
committed
ci: Show what size limit jobs exceeded the limit
1 parent 09622d6 commit 7480b25

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

dev-packages/size-limit-gh-action/index.mjs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ async function fetchPreviousComment(octokit, repo, pr) {
2727
}
2828

2929
class SizeLimit {
30-
formatBytes(size) {
31-
return bytes.format(size, { unitSeparator: ' ' });
30+
formatBytes(size, sizeLimit, passed) {
31+
if (passed) {
32+
return bytes.format(size, { unitSeparator: ' ' });
33+
}
34+
35+
return `⛔️ ${bytes.format(size, { unitSeparator: ' ' })} (max: ${bytes.format(sizeLimit, { unitSeparator: ' ' })})`;
3236
}
3337

3438
formatPercentageChange(base = 0, current = 0) {
@@ -84,7 +88,7 @@ class SizeLimit {
8488
formatSizeResult(name, base, current) {
8589
return [
8690
name,
87-
this.formatBytes(current.size),
91+
this.formatBytes(current.size, current.sizeLimit, current.passed),
8892
this.formatPercentageChange(base.size, current.size),
8993
this.formatChange(base.size, current.size),
9094
];
@@ -100,6 +104,8 @@ class SizeLimit {
100104
[result.name]: {
101105
name: result.name,
102106
size: +result.size,
107+
sizeLimit: +result.sizeLimit,
108+
passed: result.passed || false,
103109
},
104110
};
105111
}, {});

0 commit comments

Comments
 (0)