mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-04-08 11:54:12 +00:00
Integrate nicer progress bar for os:download
This commit is contained in:
parent
2b5d95af3a
commit
ffdd44752a
@ -39,4 +39,4 @@ exports.download = (id) ->
|
||||
|
||||
], (error) ->
|
||||
resin.errors.handle(error) if error?
|
||||
console.log "\n\nFinished downloading #{outputFile}"
|
||||
resin.log.info("\nFinished downloading #{outputFile}")
|
||||
|
@ -1,8 +1,8 @@
|
||||
async = require('async')
|
||||
pace = require('pace')
|
||||
fs = require('fs')
|
||||
widgets = require('../widgets/widgets')
|
||||
server = require('../../server/server')
|
||||
ProgressBar = require('progress')
|
||||
|
||||
exports.remove = (name, confirmAttribute, deleteFunction, outerCallback) ->
|
||||
async.waterfall([
|
||||
@ -21,6 +21,8 @@ exports.remove = (name, confirmAttribute, deleteFunction, outerCallback) ->
|
||||
|
||||
exports.downloadFile = (url, dest, callback) ->
|
||||
bar = null
|
||||
received = 0
|
||||
|
||||
server.request
|
||||
method: 'GET'
|
||||
url: url
|
||||
@ -28,6 +30,14 @@ exports.downloadFile = (url, dest, callback) ->
|
||||
, (error) ->
|
||||
return callback(error)
|
||||
, (state) ->
|
||||
return if not state?
|
||||
bar ?= pace(state.total)
|
||||
bar.op(state.received)
|
||||
|
||||
bar ?= new ProgressBar 'Downloading device OS [:bar] :percent :etas',
|
||||
complete: '='
|
||||
incomplete: ' '
|
||||
width: 40
|
||||
total: state.total
|
||||
|
||||
return if bar.complete or not state?
|
||||
|
||||
bar.tick(state.received - received)
|
||||
received = state.received
|
||||
|
@ -54,6 +54,6 @@
|
||||
"pubnub": "~3.7.0",
|
||||
"request-progress": "~0.3.1",
|
||||
"progress-bar": "~0.1.1",
|
||||
"pace": "0.0.4"
|
||||
"progress": "~1.1.8"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user