Browse Source

Only show update notifications when loaded from npm (#606)

* Revert "Brought the update notification back"

This reverts commit 5d3d9d4f37.

* add _npmPkg to pkg when now is installed via npm

* Prettified it

* Set _npmPkg to null
master
Igor Klopov 8 years ago
committed by Leo Lamprecht
parent
commit
3ef666ba8d
  1. 16
      bin/now.js
  2. 9
      lib/pkg.js

16
bin/now.js

@ -26,15 +26,17 @@ try {
// Utilities
const pkg = require('../lib/pkg')
const notifier = updateNotifier({ pkg })
const update = notifier.update
if (pkg._npmPkg) {
const notifier = updateNotifier({ pkg })
const update = notifier.update
if (update) {
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}`
if (update) {
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}`
notifier.notify({ message })
notifier.notify({ message })
}
}
// This command will be run if no other sub command is specified

9
lib/pkg.js

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

Loading…
Cancel
Save