Skip to content

Commit

Permalink
fix: adjust more complex var whitespacing
Browse files Browse the repository at this point in the history
  • Loading branch information
castastrophe committed May 3, 2024
1 parent c07a9c7 commit bf9ccf5
Show file tree
Hide file tree
Showing 26 changed files with 2,570 additions and 813 deletions.
32 changes: 5 additions & 27 deletions .github/actions/file-diff/index.js
Expand Up @@ -85,8 +85,6 @@ async function run() {
`**Total size**: ${bytesToSize(overallHeadSize)}<sup>*</sup>`,
];

let summaryTable = [];

if (sections.length === 0) {
summary.push(...["", " 🎉 No changes detected in any packages"]);
} else {
Expand All @@ -96,7 +94,7 @@ async function run() {
*/
let changeSummary = "";
if (baseOutput.size > 0 && hasBase && hasChange) {
changeSummary = `**Total change (Δ)**: ${printChange(overallHeadSize, overallBaseSize)} (${printPercentChange(overallHeadSize, overallBaseSize)})`;
changeSummary = `**Total change (Δ)**: ${printChange(overallBaseSize, overallHeadSize)} (${printPercentChange(overallHeadSize, overallBaseSize)})`;
} else if (baseOutput.size > 0 && hasBase && !hasChange) {
changeSummary = `No change in file sizes`;
}
Expand All @@ -105,15 +103,11 @@ async function run() {
summary.push(
changeSummary,
"",
"<small><em>Table reports on changes to a package's main file. Other changes can be found in the collapsed <a href=\"#details\">Details</a> section below.</em></small>",
""
);
}

markdown.push(
"<a name=\"details\"></a>",
`<details>`,
`<summary><b>Details</b></summary>`,
""
);

Expand Down Expand Up @@ -151,10 +145,6 @@ async function run() {
) {
data.push(printChange(headMainSize, baseMainSize));
}

if (data.length > 0) {
summaryTable.push([name, bytesToSize(headMainSize), data]);
}
}


Expand All @@ -180,7 +170,7 @@ async function run() {
isRemoved(headByteSize, baseByteSize) ? " - " : bytesToSize(headByteSize),
...(hasBase ? [
bytesToSize(baseByteSize),
isRemoved(headByteSize, baseByteSize) ? "🚨 deleted, moved, or renamed" : isNew(headByteSize, baseByteSize) ? "🎉 **new**" : `${printChange(headByteSize, baseByteSize)}${difference(headByteSize, baseByteSize) !== 0 ? ` (${printPercentChange(headByteSize , baseByteSize)})` : ""}`,
isRemoved(headByteSize, baseByteSize) ? "🚨 deleted, moved, or renamed" : isNew(headByteSize, baseByteSize) ? "🎉 **new**" : `${printChange(headByteSize, baseByteSize)}${difference(baseByteSize, headByteSize) !== 0 ? ` (${printPercentChange(headByteSize , baseByteSize)})` : ""}`,
] : []),
]
];
Expand All @@ -193,18 +183,7 @@ async function run() {
markdown.push(...md);
});

markdown.push("", `</details>`);
}

if (summaryTable.length > 0) {
// Add the headings to the summary table if it contains data
summaryTable = [
["Package", "Size", ...(hasBase ? ["Δ"] : [])],
["-", "-", ...(hasBase ? ["-"] : [])],
...summaryTable,
];

summary.push(...summaryTable.map((row) => `| ${row.join(" | ")} |`));
markdown.push("");
}

markdown.push(
Expand Down Expand Up @@ -276,7 +255,7 @@ const isNew = (v1, v0) => (v1 && v1 > 0) && (!v0 || v0 === 0);
* @param {number} difference
* @returns {string}
*/
const printChange = function (v0, v1) {
const printChange = function (v1, v0) {
/** Calculate the change in size: v1 - v0 = change */
const d = difference(v1, v0);
return d === 0
Expand Down Expand Up @@ -321,9 +300,8 @@ const makeTable = function (PACKAGES, filePath, path) {
// Check if a minified output of this file exists
if (existsSync(join(dirname(packagePath), main.replace(/\.css$/, ".min.css")))) {
mainFile = mainFile.replace(/\.css$/, ".min.css");
} else {

}
}
}

const mainFileOnly = [...fileMap.keys()].filter((file) => file.endsWith(mainFile));
Expand Down

0 comments on commit bf9ccf5

Please sign in to comment.