Skip to content

Commit

Permalink
fix: improve filesize output
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Apr 21, 2018
1 parent 74d437b commit 966756e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/commands/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ export default class UpdateCommand extends Command {
const {version, channel} = manifest
cli.action.start(`${this.config.name}: Updating CLI from ${color.green(this.config.version)} to ${color.green(version)}${channel === 'stable' ? '' : ' (' + color.yellow(channel) + ')'}`)
const http: typeof HTTP = require('http-call').HTTP
const filesize = require('filesize').partial({unix: true})
const filesize = (n: number): string => {
const [num, suffix] = require('filesize')(n, {output: 'array'})
return num.toFixed(1) + ` ${suffix}`
}
const output = path.join(this.clientRoot, version)

const {response: stream} = await http.stream(manifest.gz)
Expand All @@ -73,7 +76,7 @@ export default class UpdateCommand extends Command {
// TODO: use cli.action.type
if ((cli.action as any).frames) {
// if spinner action
let total = stream.headers['content-length']
let total = parseInt(stream.headers['content-length']!, 10)
let current = 0
const updateStatus = _.throttle(
(newStatus: string) => {
Expand Down

0 comments on commit 966756e

Please sign in to comment.