Skip to content

Commit 7abd2f6

Browse files
committed
Simplify/clarify logic
1 parent 3303188 commit 7abd2f6

File tree

1 file changed

+3
-8
lines changed
  • packages/cli-kit/src/private/node/ui/components

1 file changed

+3
-8
lines changed

packages/cli-kit/src/private/node/ui/components/Tasks.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,9 @@ function Tasks<TContext>({
8181
const {twoThirds} = useLayout()
8282
let loadingBar = new Array(twoThirds).fill(loadingBarChar).join('')
8383
if (noColor ?? !shouldDisplayColors()) {
84-
// fill loading bar with the no color chars, repeating until the length is two thirds but only using a whole number repeat of the no color chars
85-
const repeatCount = Math.floor(twoThirds / gradualHillString.length)
86-
if (repeatCount === 0) {
87-
const shortRepeatCount = Math.floor(twoThirds / hillString.length)
88-
loadingBar = hillString.repeat(Math.max(1, shortRepeatCount))
89-
} else {
90-
loadingBar = gradualHillString.repeat(repeatCount)
91-
}
84+
const fittingPattern = gradualHillString.length <= twoThirds ? gradualHillString : hillString
85+
const fullyFittingRepeats = Math.floor(twoThirds / fittingPattern.length)
86+
loadingBar = fittingPattern.repeat(Math.max(1, fullyFittingRepeats))
9287
}
9388
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
9489
const [currentTask, setCurrentTask] = useState<Task<TContext>>(tasks[0]!)

0 commit comments

Comments
 (0)