Browse files

do not show progress bar if we didn't get content-length

  • Loading branch information...
1 parent 2ab8d1c commit f87a230513b13d9fb044503fb793f9b286b1b42a @Shogun147 committed Jan 7, 2014
Showing with 12 additions and 10 deletions.
  1. +12 −10 bin/modules
View
22 bin/modules
@@ -163,7 +163,6 @@ App.command('install <name> [url]')
.description('install or reinstall application module')
.action(function(name, url) {
var ProgressBar = require('progress');
- var Bar = null;
var req = null;
var username = null;
var version = null;
@@ -263,16 +262,19 @@ App.command('install <name> [url]')
return next('Module request failed! Unexpected content type, module must be gzipped tar-ball.');
}
- Bar = new ProgressBar(' :etas'.blue +' [:bar] ' + ':percent'.green + eol, {
- complete: '=',
- incomplete: ' ',
- width: 40,
- total: parseInt(response.headers['content-length'], 10)
- });
+ var length = parseInt(response.headers['content-length'], 10);
+ if (!isNaN(length)) {
+ var Bar = new ProgressBar(' :etas'.blue +' [:bar] ' + ':percent'.green + eol, {
+ complete: '=',
+ incomplete: ' ',
+ width: 40,
+ total: length
+ });
- req.on('data', function(chunk) {
- Bar.tick(chunk.length);
- });
+ req.on('data', function(chunk) {
+ Bar.tick(chunk.length);
+ });
+ }
function abort() {
req.abort();

0 comments on commit f87a230

Please sign in to comment.