Skip to content

Commit

Permalink
Output files sizes in test package script
Browse files Browse the repository at this point in the history
  • Loading branch information
ahosgood committed Sep 11, 2024
1 parent 9ec6f66 commit 29f3ac3
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tasks/test-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,3 +351,29 @@ checkForClasses.forEach((cssClass) => {
throw new Error("CSS test failed");
}
});

console.log("\n");

console.log(`Testing file sizes`);
const filesToCheckSize = [
"all.css",
"font-awesome.css",
"ie.css",
"print.css",
"prototype-kit.css",
"all.js",
"analytics.js",
"all+analytics.js",
];
const longestFilenameToCheckSize = filesToCheckSize.reduce(
(longest, file) => (file.length > longest ? file.length : longest),
0,
);
console.log(`${"FILE".padEnd(longestFilenameToCheckSize)} SIZE`);
console.log(`${"".padEnd(longestFilenameToCheckSize, "-")}---------`);
filesToCheckSize.forEach(async (file) => {
const fileStats = await fs.promises.stat(`package/nationalarchives/${file}`);
console.log(
`${file.padEnd(longestFilenameToCheckSize)} ${Math.round(fileStats.size / 1000)} KB`,
);
});

0 comments on commit 29f3ac3

Please sign in to comment.