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,13 +114,17 @@ export default class Server { ...@@ -114,13 +114,17 @@ export default class Server {
async prepare () { async prepare () {
if (this.dev && process.stdout.isTTY) { if (this.dev && process.stdout.isTTY) {
const checkForUpdate = require('update-check') try {
const update = await checkForUpdate(pkg, { const checkForUpdate = require('update-check')
distTag: pkg.version.includes('canary') ? 'canary' : 'latest' const update = await checkForUpdate(pkg, {
}) distTag: pkg.version.includes('canary') ? 'canary' : 'latest'
if (update) { })
// bgRed from chalk if (update) {
console.log(`\u001B[41mUPDATE AVAILABLE\u001B[49m The latest version of \`next\` is ${update.latest}`) // bgRed from chalk
console.log(`\u001B[41mUPDATE AVAILABLE\u001B[49m The latest version of \`next\` is ${update.latest}`)
}
} catch (err) {
console.error('Error checking updates', err)
} }
} }
......
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