Unverified Commit 79fb13e5 authored by Joe Haddad's avatar Joe Haddad Committed by GitHub

Builds with Warnings Still Complete (#10498)

parent 189fc985
...@@ -388,17 +388,20 @@ export default async function build(dir: string, conf = null): Promise<void> { ...@@ -388,17 +388,20 @@ export default async function build(dir: string, conf = null): Promise<void> {
) )
} }
throw new Error('> Build failed because of webpack errors') throw new Error('> Build failed because of webpack errors')
} else if (result.warnings.length > 0) {
console.warn(chalk.yellow('Compiled with warnings.\n'))
console.warn(result.warnings.join('\n\n'))
console.warn()
} else { } else {
console.log(chalk.green('Compiled successfully.\n'))
telemetry.record( telemetry.record(
eventBuildCompleted(pagePaths, { eventBuildCompleted(pagePaths, {
durationInSeconds: webpackBuildEnd[0], durationInSeconds: webpackBuildEnd[0],
}) })
) )
if (result.warnings.length > 0) {
console.warn(chalk.yellow('Compiled with warnings.\n'))
console.warn(result.warnings.join('\n\n'))
console.warn()
} else {
console.log(chalk.green('Compiled successfully.\n'))
}
} }
const postBuildSpinner = createSpinner({ const postBuildSpinner = createSpinner({
prefixText: 'Automatically optimizing pages', prefixText: 'Automatically optimizing pages',
......
function a(v) {
return v
}
;['index.js'].forEach(f => {
require(a('./' + f))
})
export default () => 'Warn'
...@@ -93,6 +93,26 @@ describe('Telemetry CLI', () => { ...@@ -93,6 +93,26 @@ describe('Telemetry CLI', () => {
expect(stderr2).toMatch(/isSrcDir.*?true/) expect(stderr2).toMatch(/isSrcDir.*?true/)
}) })
it('logs completed `next build` with warnings', async () => {
await fs.rename(
path.join(appDir, 'pages', 'warning.skip'),
path.join(appDir, 'pages', 'warning.js')
)
const { stderr } = await runNextCommand(['build', appDir], {
stderr: true,
env: {
NEXT_TELEMETRY_DEBUG: 1,
},
})
await fs.rename(
path.join(appDir, 'pages', 'warning.js'),
path.join(appDir, 'pages', 'warning.skip')
)
expect(stderr).toMatch(/Compiled with warnings/)
expect(stderr).toMatch(/NEXT_BUILD_COMPLETED/)
})
it('detects tests correctly for `next build`', async () => { it('detects tests correctly for `next build`', async () => {
await fs.rename( await fs.rename(
path.join(appDir, 'pages', 'hello.test.skip'), path.join(appDir, 'pages', 'hello.test.skip'),
......
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