fis-command-install
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -162,7 +162,32 @@ /* | ||
.reduce(components, function(collection, component) { | ||
var SimpleTick = require('./lib/tick.js'); | ||
var ProgressBar = require('progress'); | ||
var bar; | ||
var progress = function(percent, loaded, total) { | ||
if (false && total) { | ||
bar = bar || new ProgressBar('downloading `' + component.address + '` [:bar] :percent :etas', { | ||
complete: '=', | ||
incomplete: ' ', | ||
width: 20, | ||
total: total, | ||
clear: true | ||
}); | ||
bar.update(percent); | ||
} else { | ||
bar = bar || new SimpleTick('doloading `' + component.address + '` '); | ||
bar.tick(); | ||
} | ||
}; | ||
return component | ||
.install() | ||
.install(progress) | ||
.then(function(component) { | ||
if (bar instanceof SimpleTick) { | ||
bar.clear(); | ||
} | ||
collection.push(component); | ||
@@ -169,0 +194,0 @@ return collection; |
@@ -13,3 +13,3 @@ var request = require('request'); | ||
request({ | ||
var req = request({ | ||
uri: uri, | ||
@@ -152,3 +152,3 @@ json: true, | ||
this.install = function() { | ||
this.install = function(progress) { | ||
var self = this; | ||
@@ -163,20 +163,2 @@ var Scaffold = require('fis-scaffold-kernel'); | ||
var ProgressBar = require('progress'); | ||
var bar, ticked; | ||
var progress = function(percent, loaded, total) { | ||
bar = bar || new ProgressBar('downloading `' + self.address + '` [:bar] :percent :etas', { | ||
complete: '=', | ||
incomplete: ' ', | ||
width: 20, | ||
total: total | ||
}); | ||
if (loaded - ticked) { | ||
bar.tick(loaded - ticked); | ||
} | ||
ticked = loaded; | ||
}; | ||
return new Promise(function(resolve, reject) { | ||
@@ -197,5 +179,2 @@ scaffold.download(self.address + '@' + self.version, function(error, location) { | ||
scaffold.deliver(location, target, mapping); | ||
ticked = 0; | ||
bar = null; | ||
resolve(self); | ||
@@ -202,0 +181,0 @@ }, progress); |
{ | ||
"name": "fis-command-install", | ||
"description": "fis install command.", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"author": "FIS Team <fis@baidu.com>", | ||
@@ -6,0 +6,0 @@ "homepage": "http://fis.baidu.com/", |
40296
16
908