fix(core): avoid printing 60.0s in build time logs - #8552
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
prettyTimedoes the< 60check and the minutes and seconds split on the raw value, and only rounds at the end withtoFixed(1). When the seconds part is 59.95 or more it rounds up to60.0without carrying into the minutes, so a 119.96s build is logged asbuilt in 1m 60.0s. Below one minute, 59.96s is printed as60.0s.Changes
Round the time to one decimal place first, then use that value for the
< 60check and the split. Now 119.96s is printed as2mand 59.96s as1m. Since the whole second check also sees the rounded value, 60.04s now prints1minstead of1m 0.0s. The existing test cases keep the same output.Added two cases to the existing
prettyTimetest inpackages/core/tests/helpers.test.ts. Before the fix it fails withexpected '60.0s' to deeply equal '1m'(andprettyTime(119.96)returns1m 60.0s). After the fix the test passes, along with the rest of the core unit tests.