From 9577be72ee3392efec1bdf64faa17a031d99663c Mon Sep 17 00:00:00 2001 From: fisker Date: Mon, 21 Dec 2020 16:55:23 +0800 Subject: [PATCH] Hide `Change` column if they are all `0 B` --- src/utils.js | 11 +++++++++- tests/__snapshots__/utils.spec.js.snap | 30 +++++++++++++------------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/utils.js b/src/utils.js index 1d27840..92f73e0 100644 --- a/src/utils.js +++ b/src/utils.js @@ -84,7 +84,16 @@ function markdownTable(rows) { } const [firstRow] = rows; - const columnLength = firstRow.length; + let columnLength = firstRow.length; + + // Hide `Change` column if they are all `0 B` + if (columnLength === 3 &rows.every(columns => columns[2] === '0 B')) { + columnLength -= 1; + for (const columns of rows) { + columns.pop(); + } + } + if (columnLength === 0) { return ''; } diff --git a/tests/__snapshots__/utils.spec.js.snap b/tests/__snapshots__/utils.spec.js.snap index ede05be..0a86725 100644 --- a/tests/__snapshots__/utils.spec.js.snap +++ b/tests/__snapshots__/utils.spec.js.snap @@ -13,9 +13,9 @@ exports[`diffTable 1`] = `
ℹ️ View Unchanged -| Filename | Size | Change | -| :--- | :---: | :---: | -| \`three.js\` | 300 B | 0 B | +| Filename | Size | +| :--- | :---: | +| \`three.js\` | 300 B |
@@ -31,9 +31,9 @@ exports[`diffTable 2`] = `
ℹ️ View Unchanged -| Filename | Size | Change | -| :--- | :---: | :---: | -| \`three.js\` | 300 B | 0 B | +| Filename | Size | +| :--- | :---: | +| \`three.js\` | 300 B |
@@ -96,12 +96,12 @@ exports[`diffTable 6`] = `
ℹ️ View Unchanged -| Filename | Size | Change | -| :--- | :---: | :---: | -| \`one.js\` | 5 kB | 0 B | -| \`two.js\` | -5 kB | 0 B | -| \`three.js\` | 300 B | 0 B | -| \`four.js\` | 4.5 kB | 0 B | +| Filename | Size | +| :--- | :---: | +| \`one.js\` | 5 kB | +| \`two.js\` | -5 kB | +| \`three.js\` | 300 B | +| \`four.js\` | 4.5 kB |
@@ -117,9 +117,9 @@ exports[`diffTable 7`] = `
ℹ️ View Unchanged -| Filename | Size | Change | -| :--- | :---: | :---: | -| \`three.js\` | 300 B | 0 B | +| Filename | Size | +| :--- | :---: | +| \`three.js\` | 300 B |