mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-13 08:19:50 +00:00
44 lines
1.0 KiB
CoffeeScript
44 lines
1.0 KiB
CoffeeScript
|
async = require('async')
|
||
|
_ = require('lodash-contrib')
|
||
|
npm = require('npm')
|
||
|
packageJSON = require('../../package.json')
|
||
|
|
||
|
exports.update =
|
||
|
signature: 'update'
|
||
|
description: 'update the resin cli'
|
||
|
help: '''
|
||
|
Use this command to update the Resin CLI
|
||
|
|
||
|
This command outputs information about the update process.
|
||
|
Use `--quiet` to remove that output.
|
||
|
|
||
|
Examples:
|
||
|
|
||
|
$ resin update
|
||
|
'''
|
||
|
action: (params, options, done) ->
|
||
|
async.waterfall([
|
||
|
|
||
|
(callback) ->
|
||
|
options =
|
||
|
|
||
|
# TODO: There is no way to quiet npm install completely.
|
||
|
# Some output is still shown once the module is updated
|
||
|
# https://github.com/npm/npm/issues/2040
|
||
|
loglevel: 'silent'
|
||
|
global: true
|
||
|
|
||
|
npm.load(options, _.unary(callback))
|
||
|
|
||
|
(callback) ->
|
||
|
npm.commands.update([ packageJSON.name ], callback)
|
||
|
|
||
|
(data, lite, callback) ->
|
||
|
if _.isEmpty(data)
|
||
|
return done(new Error('You are already running the latest version'))
|
||
|
|
||
|
newVersion = _.last(_.first(_.last(data)).split('@'))
|
||
|
console.info("Upgraded #{packageJSON.name} to v#{newVersion}.")
|
||
|
|
||
|
], done)
|