From 0a458eaa7e574b3a2e4dc1435746905ef469f8b4 Mon Sep 17 00:00:00 2001 From: Yuji Sugiura Date: Tue, 15 Sep 2020 17:28:17 +0900 Subject: [PATCH 1/2] Fix export-cli progress label default value --- packages/next/export/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/next/export/index.ts b/packages/next/export/index.ts index 24c69ee2844ce..0ad9823778288 100644 --- a/packages/next/export/index.ts +++ b/packages/next/export/index.ts @@ -57,7 +57,7 @@ function divideSegments(number: number, segments: number): number[] { return result } -const createProgress = (total: number, label = 'Exporting') => { +const createProgress = (total: number, label: string) => { const segments = divideSegments(total, 4) let currentSegmentTotal = segments.shift() @@ -381,7 +381,7 @@ export default async function exportApp( !options.silent && createProgress( filteredPaths.length, - `${Log.prefixes.info} ${options.statusMessage}` + `${Log.prefixes.info} ${options.statusMessage || 'Exporting'}` ) const pagesDataDir = options.buildExport ? outDir From 14f26731e0a149d05e50a66716fecdc2cf082cc7 Mon Sep 17 00:00:00 2001 From: Yuji Sugiura Date: Mon, 21 Sep 2020 15:53:34 +0900 Subject: [PATCH 2/2] Add tests --- .../pages/index.js | 1 + .../test/index.test.js | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 test/integration/export-progress-status-message/pages/index.js create mode 100644 test/integration/export-progress-status-message/test/index.test.js diff --git a/test/integration/export-progress-status-message/pages/index.js b/test/integration/export-progress-status-message/pages/index.js new file mode 100644 index 0000000000000..5c13c39dbd689 --- /dev/null +++ b/test/integration/export-progress-status-message/pages/index.js @@ -0,0 +1 @@ +export default () =>

I am a home page

diff --git a/test/integration/export-progress-status-message/test/index.test.js b/test/integration/export-progress-status-message/test/index.test.js new file mode 100644 index 0000000000000..249eea3034ca5 --- /dev/null +++ b/test/integration/export-progress-status-message/test/index.test.js @@ -0,0 +1,36 @@ +/* eslint-env jest */ + +import { join } from 'path' +import { nextBuild, nextExportDefault } from 'next-test-utils' + +jest.setTimeout(1000 * 60 * 5) +const appDir = join(__dirname, '../') + +describe('Export cli prints progress info', () => { + let buildStdout + let exportStdout + beforeAll(async () => { + const buildResult = await nextBuild(appDir, [], { stdout: true }) + buildStdout = buildResult.stdout + const exportResult = await nextExportDefault(appDir, { stdout: true }) + exportStdout = exportResult.stdout + }) + + it('build: should log with internally passed statusMessage', async () => { + const lines = buildStdout.split('\n') + // Search `info - Generating static pages (n/m)` line + const found = lines.some((line) => + /Generating static pages \(\d+\/\d+\)/.test(line) + ) + + expect(found).toBeTruthy() + }) + + it('export: should log with default label', async () => { + const lines = exportStdout.split('\n') + // Search `info - Exporting (n/m)` line + const found = lines.some((line) => /Exporting \(\d+\/\d+\)/.test(line)) + + expect(found).toBeTruthy() + }) +})