1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Catch errors from update-check (#4276)

Makes sure that Next.js can be started in development mode while being offline.
This commit is contained in:
Tim Neutkens 2018-05-05 05:49:21 -07:00 committed by GitHub
parent 6bc363e615
commit 3da0049424
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)
} }
} }