balena-cli/lib/utils/update.coffee
Juan Cruz Viotti 1cfbd4197d Improve the way the update notifier is shown
Current has the following problems:

- Our custom message gets printed even if the notifier doesn't contain
an update.

- The notifier box is deferred, therefore it's printed at the end of the
command. Since our custom message is printed at the beginning, it makes
no sense at all.
2015-10-15 09:18:45 -04:00

19 lines
605 B
CoffeeScript

updateNotifier = require('update-notifier')
isRoot = require('is-root')
packageJSON = require('../../package.json')
# `update-notifier` creates files to make the next
# running time ask for updated, however this can lead
# to ugly EPERM issues if those files are created as root.
if not isRoot()
notifier = updateNotifier(pkg: packageJSON)
exports.hasAvailableUpdate = ->
return notifier?
exports.notify = ->
return if not exports.hasAvailableUpdate()
notifier.notify(defer: false)
if notifier.update?
console.log('Notice that you might need administrator privileges depending on your setup\n')