Unverified Commit 39e688e8 authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

Fix output log extra new line (#55770)

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
parent 83bea332
......@@ -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({
......
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment