avoid run time in summary for yarn 1

This commit is contained in:
Evan Wallace
2021-03-06 04:09:37 -08:00
parent d0dde63a8a
commit 0e7c11d28e
2 changed files with 23 additions and 9 deletions

View File

@@ -608,7 +608,7 @@ func (t SummaryTable) Less(i int, j int) bool {
// Show a warning icon next to output files that are 1mb or larger
const sizeWarningThreshold = 1024 * 1024
func PrintSummary(useColor UseColor, table SummaryTable, start time.Time) {
func PrintSummary(useColor UseColor, table SummaryTable, start *time.Time) {
PrintTextWithColor(os.Stderr, useColor, func(colors Colors) string {
isProbablyWindowsCommandPrompt := false
sb := strings.Builder{}
@@ -675,7 +675,7 @@ func PrintSummary(useColor UseColor, table SummaryTable, start time.Time) {
if layoutWidth > maxPath+maxSize {
layoutWidth = maxPath + maxSize
}
sb.WriteString("\n")
sb.WriteByte('\n')
for _, entry := range table {
dir, base := entry.Dir, entry.Base
@@ -751,12 +751,17 @@ func PrintSummary(useColor UseColor, table SummaryTable, start time.Time) {
lightningSymbol = ""
}
sb.WriteString(fmt.Sprintf("\n%s%sDone in %dms%s\n\n",
// Printing the time taken is optional
if start != nil {
sb.WriteString(fmt.Sprintf("\n%s%sDone in %dms%s\n",
lightningSymbol,
colors.Green,
time.Since(start).Milliseconds(),
time.Since(*start).Milliseconds(),
colors.Default,
))
}
sb.WriteByte('\n')
return sb.String()
})
}

View File

@@ -654,7 +654,16 @@ func printSummary(logOptions logger.OutputOptions, outputFiles []OutputFile, sta
}
}
logger.PrintSummary(logOptions.Color, table, start)
// Don't print the time taken by the build if we're running under Yarn 1
// since Yarn 1 always prints its own copy of the time taken by each command
for _, env := range os.Environ() {
if strings.HasPrefix(env, "npm_config_user_agent=") && strings.Contains(env, "yarn/1.") {
logger.PrintSummary(logOptions.Color, table, nil)
return
}
}
logger.PrintSummary(logOptions.Color, table, &start)
}
func rebuildImpl(