mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-24 15:56:38 +00:00
27 lines
777 B
CoffeeScript
27 lines
777 B
CoffeeScript
|
updateNotifier = require('update-notifier')
|
||
|
packageJSON = require('../package.json')
|
||
|
updateAction = require('./actions/update')
|
||
|
|
||
|
exports.perform = (callback) ->
|
||
|
updateAction.update.action(null, null, callback)
|
||
|
|
||
|
exports.notify = (update) ->
|
||
|
return if not process.stdout.isTTY
|
||
|
|
||
|
console.log """
|
||
|
> Major update available: #{update.current} -> #{update.latest}
|
||
|
> Run resin update to update.
|
||
|
> Beware that a major release might introduce breaking changes.\n
|
||
|
"""
|
||
|
|
||
|
exports.check = (callback) ->
|
||
|
notifier = updateNotifier(pkg: packageJSON)
|
||
|
return callback() if not notifier.update?
|
||
|
|
||
|
if notifier.update.type is 'major'
|
||
|
exports.notify(notifier.update)
|
||
|
return callback()
|
||
|
|
||
|
console.log("Performing #{notifier.update.type} update, hold tight...")
|
||
|
exports.perform(callback)
|