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