Skip to content

Commit

Permalink
Hide Change column if they are all 0 B
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Dec 21, 2020
1 parent bd40149 commit 9577be7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
11 changes: 10 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 '';
}
Expand Down
30 changes: 15 additions & 15 deletions tests/__snapshots__/utils.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ exports[`diffTable 1`] = `
<details><summary>ℹ️ <strong>View Unchanged</strong></summary>
| Filename | Size | Change |
| :--- | :---: | :---: |
| \`three.js\` | 300 B | 0 B |
| Filename | Size |
| :--- | :---: |
| \`three.js\` | 300 B |
</details>
Expand All @@ -31,9 +31,9 @@ exports[`diffTable 2`] = `
<details><summary>ℹ️ <strong>View Unchanged</strong></summary>
| Filename | Size | Change |
| :--- | :---: | :---: |
| \`three.js\` | 300 B | 0 B |
| Filename | Size |
| :--- | :---: |
| \`three.js\` | 300 B |
</details>
Expand Down Expand Up @@ -96,12 +96,12 @@ exports[`diffTable 6`] = `
<details><summary>ℹ️ <strong>View Unchanged</strong></summary>
| 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 |
</details>
Expand All @@ -117,9 +117,9 @@ exports[`diffTable 7`] = `
<details><summary>ℹ️ <strong>View Unchanged</strong></summary>
| Filename | Size | Change |
| :--- | :---: | :---: |
| \`three.js\` | 300 B | 0 B |
| Filename | Size |
| :--- | :---: |
| \`three.js\` | 300 B |
</details>
Expand Down

0 comments on commit 9577be7

Please sign in to comment.