mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-04-02 15:13:28 +08:00
fix: clamp progressBar to prevent RangeError on overflow, add 10 tests
progressBar() in skill-create-output.js could crash with RangeError when percent > 100 because repeat() received a negative count. Fixed by clamping filled to [0, width]. New tests: - progressBar edge cases: 0%, 100%, and >100% confidence - Empty patterns/instincts arrays - post-edit-format: null tool_input, missing file_path, prettier failure - setup-package-manager: --detect output completeness, current marker
This commit is contained in:
@@ -53,7 +53,7 @@ function stripAnsi(str) {
|
||||
}
|
||||
|
||||
function progressBar(percent, width = 30) {
|
||||
const filled = Math.round(width * percent / 100);
|
||||
const filled = Math.min(width, Math.max(0, Math.round(width * percent / 100)));
|
||||
const empty = width - filled;
|
||||
const bar = chalk.green('█'.repeat(filled)) + chalk.gray('░'.repeat(empty));
|
||||
return `${bar} ${chalk.bold(percent)}%`;
|
||||
|
||||
Reference in New Issue
Block a user