Browse Source

Make update notifications work again (#610)

* Revert "Disable update-notifier (#609)"

This reverts commit b7a8f23475.

* pkg@3.0.6

* output 'please update' for both npm and non-npm install
master
Igor Klopov 8 years ago
committed by Guillermo Rauch
parent
commit
d186767b58
  1. 11
      bin/now.js
  2. 9
      lib/pkg.js
  3. 2
      package.json

11
bin/now.js

@ -26,14 +26,19 @@ try {
// Utilities // Utilities
const pkg = require('../lib/pkg') const pkg = require('../lib/pkg')
if (!process.pkg) { if (process.pkg) {
const notifier = updateNotifier({ pkg }) const notifier = updateNotifier({ pkg })
const update = notifier.update const update = notifier.update
if (update) { if (update) {
let message = `Update available! ${chalk.red(update.current)}${chalk.green(update.latest)} \n` let message = `Update available! ${chalk.red(update.current)}${chalk.green(update.latest)} \n`
message += `Run ${chalk.magenta('npm i -g now')} to update!\n` message += `${chalk.magenta('Changelog:')} https://github.com/zeit/now-cli/releases/tag/${update.latest}\n`
message += `${chalk.magenta('Changelog:')} https://github.com/zeit/now-cli/releases/tag/${update.latest}`
if (pkg._npmPkg) {
message += `Run ${chalk.magenta('npm i -g now')} to update!`
} else {
message += `Please download binaries from https://zeit.co/download`
}
notifier.notify({ message }) notifier.notify({ message })
} }

9
lib/pkg.js

@ -1,10 +1,13 @@
/* eslint-disable import/no-unresolved */ /* eslint-disable import/no-unresolved */
let pkg const path = require('path')
const pkg = require('../package.json')
try { try {
pkg = require('../package.json') const distDir = path.dirname(process.execPath)
pkg._npmPkg = require(path.join(distDir, '../../package.json'))
} catch (err) { } catch (err) {
pkg = require('../../package.json') pkg._npmPkg = null
} }
module.exports = pkg module.exports = pkg

2
package.json

@ -94,7 +94,7 @@
"ms": "2.0.0", "ms": "2.0.0",
"node-fetch": "1.7.0", "node-fetch": "1.7.0",
"ora": "1.2.0", "ora": "1.2.0",
"pkg": "3.0.5", "pkg": "3.0.6",
"prettier": "1.3.1", "prettier": "1.3.1",
"printf": "0.2.5", "printf": "0.2.5",
"progress": "2.0.0", "progress": "2.0.0",

Loading…
Cancel
Save