Skip to content

Commit

Permalink
Builds with Warnings Still Complete
Browse files Browse the repository at this point in the history
  • Loading branch information
Timer committed Feb 11, 2020
1 parent 2ff0913 commit 28fe233
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/next/build/index.ts
Expand Up @@ -388,17 +388,20 @@ export default async function build(dir: string, conf = null): Promise<void> {
)
}
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 {
console.log(chalk.green('Compiled successfully.\n'))
telemetry.record(
eventBuildCompleted(pagePaths, {
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({
prefixText: 'Automatically optimizing pages',
Expand Down
8 changes: 8 additions & 0 deletions test/integration/telemetry/pages/warning.skip
@@ -0,0 +1,8 @@
function a(v) {
return v
}
;['index.js'].forEach(f => {
require(a('./' + f))
})

export default () => 'Warn'
20 changes: 20 additions & 0 deletions test/integration/telemetry/test/index.test.js
Expand Up @@ -93,6 +93,26 @@ describe('Telemetry CLI', () => {
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 () => {
await fs.rename(
path.join(appDir, 'pages', 'hello.test.skip'),
Expand Down

0 comments on commit 28fe233

Please sign in to comment.