Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced the update checker #347

Merged
merged 2 commits into from
Apr 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions bin/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ const args = require('args')
const compress = require('micro-compress')
const detect = require('detect-port')
const { coroutine } = require('bluebird')
const updateNotifier = require('@zeit/check-updates')
const { red } = require('chalk')
const checkForUpdate = require('update-check')
const { red, bold } = require('chalk')
const nodeVersion = require('node-version')
const cert = require('openssl-self-signed-certificate')
const boxen = require('boxen')

// Utilities
const pkg = require('../package')
Expand All @@ -31,12 +32,6 @@ if (nodeVersion.major < 6) {
process.exit(1)
}

// Let user know if there's an update
// This isn't important when deployed to production
if (process.env.NODE_ENV !== 'production' && pkg.dist) {
updateNotifier(pkg, 'serve')
}

// Register the list of options
args.options(options)

Expand Down Expand Up @@ -85,7 +80,24 @@ const server = flags.ssl

let { port } = flags

detect(port).then(open => {
detect(port).then(async open => {
const { NODE_ENV } = process.env
const update = await checkForUpdate(pkg)

if (NODE_ENV !== 'production' && update) {
const message = `${bold(
'UPDATE AVAILABLE:'
)} The latest version of \`serve\` is ${update.latest}`

console.log(
boxen(message, {
padding: 1,
borderColor: 'green',
margin: 1
})
)
}

let inUse = open !== port

if (inUse) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"xo": "0.20.3"
},
"dependencies": {
"@zeit/check-updates": "1.1.0",
"args": "3.0.8",
"basic-auth": "2.0.0",
"bluebird": "3.5.1",
Expand All @@ -72,6 +71,7 @@
"opn": "5.2.0",
"path-is-inside": "1.0.2",
"path-type": "3.0.0",
"send": "0.16.2"
"send": "0.16.2",
"update-check": "1.2.0"
}
}
Loading