Skip to content

Commit

Permalink
Disable cache warning on supported platforms (vercel#12495)
Browse files Browse the repository at this point in the history
  • Loading branch information
Timer authored May 5, 2020
1 parent 467b65a commit adb14c9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/next/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default async function build(dir: string, conf = null): Promise<void> {
headers.push(..._headers)
}

if (ciEnvironment.isCI) {
if (ciEnvironment.isCI && !ciEnvironment.hasNextSupport) {
const cacheDir = path.join(distDir, 'cache')
const hasCache = await promises
.access(cacheDir)
Expand Down
5 changes: 5 additions & 0 deletions packages/next/telemetry/ci-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ const isHeroku =

export const isCI = isZeitNow || isHeroku || _isCI
export const name = isZeitNow ? 'ZEIT Now' : isHeroku ? 'Heroku' : _name

// This boolean indicates if the CI platform has first-class Next.js support,
// which allows us to disable certain messages which do not require their
// action.
export const hasNextSupport = Boolean(isZeitNow)
14 changes: 12 additions & 2 deletions test/integration/build-warnings/test/index.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-env jest */
/* global jasmine */
import { join } from 'path'
import { remove } from 'fs-extra'
import { nextBuild, File, waitFor } from 'next-test-utils'
import { File, nextBuild, waitFor } from 'next-test-utils'
import { join } from 'path'

jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 1
const appDir = join(__dirname, '../')
Expand Down Expand Up @@ -61,6 +61,16 @@ describe('Build warnings', () => {
expect(stdout).not.toContain('no-cache')
})

it('should not warn about missing cache on supported platforms', async () => {
await remove(join(appDir, '.next'))

const { stdout } = await nextBuild(appDir, undefined, {
stdout: true,
env: { CI: '1', NOW_BUILDER: '1' },
})
expect(stdout).not.toContain('no-cache')
})

it('should warn about missing cache in CI', async () => {
await remove(join(appDir, '.next'))

Expand Down

0 comments on commit adb14c9

Please sign in to comment.