Commit b5599525 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig

fix

parent 79f9651b
...@@ -49,6 +49,10 @@ export const createProgress = (total: number, label: string) => { ...@@ -49,6 +49,10 @@ export const createProgress = (total: number, label: string) => {
interval: 200, interval: 200,
}, },
}) })
if (process.stdout.isTTY) {
// createSpinner logs the initial state, but doesn't do anything afterwards anyway.
progressSpinner = undefined
}
const run = () => { const run = () => {
curProgress++ curProgress++
...@@ -72,7 +76,7 @@ export const createProgress = (total: number, label: string) => { ...@@ -72,7 +76,7 @@ export const createProgress = (total: number, label: string) => {
const isFinished = curProgress === total const isFinished = curProgress === total
const message = `${label} (${curProgress}/${total})` const message = `${label} (${curProgress}/${total})`
if (process.stdout.isTTY && progressSpinner && !isFinished) { if (progressSpinner && !isFinished) {
progressSpinner.setText(message) progressSpinner.setText(message)
} else { } else {
progressSpinner?.stop() progressSpinner?.stop()
...@@ -87,7 +91,6 @@ export const createProgress = (total: number, label: string) => { ...@@ -87,7 +91,6 @@ export const createProgress = (total: number, label: string) => {
const clear = () => { const clear = () => {
if ( if (
process.stdout.isTTY &&
progressSpinner && progressSpinner &&
// Ensure only reset and clear once to avoid set operation overflow in ora // Ensure only reset and clear once to avoid set operation overflow in ora
progressSpinner.isSpinning progressSpinner.isSpinning
......
...@@ -67,11 +67,12 @@ describe('Cache Components Errors', () => { ...@@ -67,11 +67,12 @@ describe('Cache Components Errors', () => {
`) `)
} else { } else {
expect(output).toMatchInlineSnapshot(` expect(output).toMatchInlineSnapshot(`
"[<timestamp>] This is a console log from a server component page "[<timestamp>] This is a console log from a server component page
[<timestamp>] This is a console log from a server component page [<timestamp>] This is a console log from a server component page
[<timestamp>] Collecting build traces ... [<timestamp>] Collecting build traces ...
[<timestamp>]" [<timestamp>] ✓ Collecting build traces in 3.1s
`) [<timestamp>]"
`)
} }
}) })
} }
......
...@@ -51,8 +51,8 @@ describe('Polyfills', () => { ...@@ -51,8 +51,8 @@ describe('Polyfills', () => {
it('should contain generated page count in output', async () => { it('should contain generated page count in output', async () => {
expect(output).toContain('Generating static pages (0/5)') expect(output).toContain('Generating static pages (0/5)')
expect(output).toContain('Generating static pages (5/5)') expect(output).toContain('Generating static pages (5/5)')
// we should only have 1 segment and the initial message logged out // we should have 4 segment, the initial message, and the final one with time
expect(output.match(/Generating static pages/g).length).toBe(5) expect(output.match(/Generating static pages/g).length).toBe(6)
}) })
} }
) )
......
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