Skip to content

Commit

Permalink
feat: Print 0 size as unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
d4rkr00t committed Apr 8, 2018
1 parent e4545da commit f67e38b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/print.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,17 @@ const printType = (module, by, limit) => {
const printSize = (size /*: number */, mod = false) => {
const sizeInKiB = Math.ceil(size / 1024);
const level =
sizeInKiB > 20
? "red"
: sizeInKiB < 20 && sizeInKiB > 10 ? "yellow" : "default";
sizeInKiB === 0
? "unknown"
: sizeInKiB > 20
? "red"
: sizeInKiB < 20 && sizeInKiB > 10 ? "yellow" : "default";
const sizeFormatted =
level === "default" ? sizeInKiB + " KiB" : chalk[level](sizeInKiB + " KiB");
level === "unknown"
? chalk.dim("unknown")
: level === "default"
? sizeInKiB + " KiB"
: chalk[level](sizeInKiB + " KiB");
return `${chalk.magenta("size")}: ${sizeFormatted}${
mod ? chalk.dim(" [for all included files]") : ""
}`;
Expand Down

0 comments on commit f67e38b

Please sign in to comment.