-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(builder): improve time logs format (#4702)
* feat(builder): improve time logs format * chore: improve * fix: only remove digits for ms time * chore: fix filesize round * chore: update doc
- Loading branch information
1 parent
6cefc25
commit 2675812
Showing
11 changed files
with
42 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
'@modern-js/builder-webpack-provider': patch | ||
'@modern-js/builder-rspack-provider': patch | ||
'@modern-js/builder-shared': patch | ||
--- | ||
|
||
feat(builder): improve time logs format | ||
|
||
feat(builder): 优化时间日志的格式 |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import basePrettyTime from '../compiled/pretty-time'; | ||
import chalk from '@modern-js/utils/chalk'; | ||
|
||
const TIME_REGEXP = /([\d.]+)([a-zA-Z]+)/; | ||
|
||
export const prettyTime = (time: number | [number, number], digits = 1) => { | ||
const timeStr: string = basePrettyTime(time, digits); | ||
|
||
return timeStr.replace(TIME_REGEXP, (match, p1, p2) => { | ||
if (p1 && p2) { | ||
let time = p1; | ||
|
||
// remove digits of ms time | ||
if (p2 === 'ms') { | ||
time = Number(time).toFixed(0); | ||
} | ||
|
||
return `${chalk.bold(time)} ${p2}`; | ||
} | ||
return chalk.bold(match); | ||
}); | ||
}; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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