Skip to content

Commit

Permalink
log message when stdin makes serve exit (evanw#3712)
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Apr 1, 2024
1 parent 7267a1f commit bfe6f51
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions cmd/esbuild/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,16 @@ func main() {
for {
_, err := os.Stdin.Read(buffer)
if err != nil {
// Mention why watch mode was stopped to reduce confusion, and
// call out "--watch=forever" to get the alternative behavior
if isWatch {
if options := logger.OutputOptionsForArgs(osArgs); options.LogLevel <= logger.LevelInfo {
if options := logger.OutputOptionsForArgs(osArgs); options.LogLevel <= logger.LevelInfo {
if isWatch {
// Mention why watch mode was stopped to reduce confusion, and
// call out "--watch=forever" to get the alternative behavior
logger.PrintTextWithColor(os.Stderr, options.Color, func(colors logger.Colors) string {
return fmt.Sprintf("%s[watch] stopped because stdin was closed (use \"--watch=forever\" to keep watching even after stdin is closed)%s\n", colors.Dim, colors.Reset)
return fmt.Sprintf("%s[watch] stopped automatically because stdin was closed (use \"--watch=forever\" to keep watching even after stdin is closed)%s\n", colors.Dim, colors.Reset)
})
} else if isServeOrWatch {
logger.PrintTextWithColor(os.Stderr, options.Color, func(colors logger.Colors) string {
return fmt.Sprintf("%s[serve] stopped automatically because stdin was closed (keep stdin open to continue serving)%s\n", colors.Dim, colors.Reset)
})
}
}
Expand Down

0 comments on commit bfe6f51

Please sign in to comment.