Skip to content

Commit

Permalink
fix: build time display 7m 60s (#19108)
Browse files Browse the repository at this point in the history
Co-authored-by: chenyingjie <chenyingjie@wezonet.com>
  • Loading branch information
jj19100 and chenyingjie authored Jan 7, 2025
1 parent da0caf5 commit cf0d2c8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/vite/src/node/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`}`
}

/**
Expand Down

0 comments on commit cf0d2c8

Please # to comment.