Skip to content

Commit

Permalink
Add warning when compressed runtime is overall 2MB (#50)
Browse files Browse the repository at this point in the history
fix #37
  • Loading branch information
chevdor authored Jul 6, 2022
1 parent 5a8492c commit ce8a40a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/src/runtime_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,16 @@ impl Display for RuntimeInfo {
let size_mb: f64 = self.size as f64 / 1024.0 / 1024.0;
let width_emoji = 1;
let width_title = 25;
const MAX_SIZE_COMPRESSED: f64 = 2_f64;

writeln!(
fmt,
"{:<width_emoji$} {:<width_title$} {:.3?} MB ({} bytes)",
"{:<width_emoji$} {:<width_title$} {:.3?} MB ({} bytes) {warning}",
"🏋️ ",
"Runtime size:",
size_mb,
self.size.to_formatted_string(&Locale::en)
self.size.to_formatted_string(&Locale::en),
warning = if size_mb >= MAX_SIZE_COMPRESSED { "⚠️ HEAVY" } else { "" }
)?;
if self.compression.compressed() {
writeln!(
Expand Down

0 comments on commit ce8a40a

Please sign in to comment.