Unverified Commit 3da00494 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Catch errors from update-check (#4276)

Makes sure that Next.js can be started in development mode while being offline.
parent 6bc363e6
...@@ -114,6 +114,7 @@ export default class Server { ...@@ -114,6 +114,7 @@ export default class Server {
async prepare () { async prepare () {
if (this.dev && process.stdout.isTTY) { if (this.dev && process.stdout.isTTY) {
try {
const checkForUpdate = require('update-check') const checkForUpdate = require('update-check')
const update = await checkForUpdate(pkg, { const update = await checkForUpdate(pkg, {
distTag: pkg.version.includes('canary') ? 'canary' : 'latest' distTag: pkg.version.includes('canary') ? 'canary' : 'latest'
...@@ -122,6 +123,9 @@ export default class Server { ...@@ -122,6 +123,9 @@ export default class Server {
// bgRed from chalk // bgRed from chalk
console.log(`\u001B[41mUPDATE AVAILABLE\u001B[49m The latest version of \`next\` is ${update.latest}`) console.log(`\u001B[41mUPDATE AVAILABLE\u001B[49m The latest version of \`next\` is ${update.latest}`)
} }
} catch (err) {
console.error('Error checking updates', err)
}
} }
await this.defineRoutes() await this.defineRoutes()
......
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