Skip to content

Commit b6bf070

Browse files
committed
fix: don't show consumption in percentage if no budget is set
1 parent 4702036 commit b6bf070

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased Changes
44

5+
- Fixed usage percentage to no longer be printed when no budget is set
6+
57
## 0.10.0
68

79
### Tools

src/index.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -669,9 +669,17 @@ const main = async () => {
669669

670670
// Show budget status if available
671671
if (response.budgetState) {
672-
const usagePercentage =
673-
(response.budgetState.totalBytesScanned / response.budgetState.budgetLimitBytes) * 100;
674-
result += ` (Session total: ${(response.budgetState.totalBytesScanned / (1000 * 1000 * 1000)).toFixed(2)} GB / ${response.budgetState.budgetLimitGB} GB budget, ${usagePercentage.toFixed(1)}% used)`;
672+
const scannedGB = (response.budgetState.totalBytesScanned / (1000 * 1000 * 1000)).toFixed(2);
673+
674+
if (response.budgetState.budgetLimitGB > 0) {
675+
const usagePercentage = (
676+
(response.budgetState.totalBytesScanned / response.budgetState.budgetLimitBytes) *
677+
100
678+
).toFixed(1);
679+
result += ` (Session total: ${scannedGB} GB / ${response.budgetState.budgetLimitGB} GB budget, ${usagePercentage}% used)`;
680+
} else {
681+
result += ` (Session total: ${scannedGB} GB)`;
682+
}
675683
}
676684
result += '\n';
677685

0 commit comments

Comments
 (0)