Skip to content

Commit

Permalink
Fix output log extra new line (#55770)
Browse files Browse the repository at this point in the history
For progress spinner, only log new line when `process.stdout.isTTY`

## After

![image](https://github.com/vercel/next.js/assets/4800338/cb850b22-0985-4129-ba5e-961f3c914701)

## Before

![image](https://github.com/vercel/next.js/assets/4800338/5c69d964-74dd-432f-901d-ad86a4307422)

Adding extra space make sure there's loading bar between prefix text and spinner 

![image](https://github.com/vercel/next.js/assets/4800338/b99f7ec6-af9d-445b-a6ea-3d1592b4553d)


Closes NEXT-1647
  • Loading branch information
huozhi committed Sep 21, 2023
1 parent 83bea33 commit 39e688e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/next/src/build/spinner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export default function createSpinner(
) {
let spinner: undefined | ora.Ora

const prefixText = ` ${Log.prefixes.info} ${text}`
const prefixText = ` ${Log.prefixes.info} ${text} `
// Add \r at beginning to reset the current line of loading status text
const suffixText = `\r ${Log.prefixes.event} ${text}`
const suffixText = `\r ${Log.prefixes.event} ${text} `

if (process.stdout.isTTY) {
spinner = ora({
Expand Down
4 changes: 3 additions & 1 deletion packages/next/src/export/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ const createProgress = (total: number, label: string) => {
// If it's 100% progressed, then we don't need to break a new line to avoid logging from routes while building.
const newText = `\r ${
isFinished ? Log.prefixes.event : Log.prefixes.info
} ${label} (${curProgress}/${total})${isFinished ? '' : '\n'}`
} ${label} (${curProgress}/${total}) ${
isFinished ? '' : process.stdout.isTTY ? '\n' : '\r'
}`
if (progressSpinner) {
progressSpinner.text = newText
} else {
Expand Down

0 comments on commit 39e688e

Please sign in to comment.