From ca08cbb8f7cfea3344e5042645c8b7bbf58aaafc Mon Sep 17 00:00:00 2001 From: chenyingjie Date: Tue, 31 Dec 2024 18:39:54 +0800 Subject: [PATCH] fix: build time display 7m 60s --- packages/vite/src/node/utils.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index 233f96810da833..65316c1f6fa8de 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -1501,11 +1501,17 @@ export function displayTime(time: number): string { return `${time.toFixed(2)}s` } - const mins = parseInt((time / 60).toString()) - const seconds = time % 60 + // Calculate total minutes and remaining seconds + const mins = Math.floor(time / 60) + const seconds = Math.round(time % 60) + + // Handle case where seconds rounds to 60 + if (seconds === 60) { + return `${mins + 1}m` + } // display: {X}m {Y}s - return `${mins}m${seconds < 1 ? '' : ` ${seconds.toFixed(0)}s`}` + return `${mins}m${seconds < 1 ? '' : ` ${seconds}s`}` } /**