fis-command-install
Advanced tools
Comparing version 0.1.5 to 0.1.6
@@ -131,5 +131,18 @@ /* | ||
var collector = require('./lib/collector.js'); | ||
return collector(components) | ||
return Promise | ||
.try(function() { | ||
var collector = require('./lib/collector.js'); | ||
var SimpleTick = require('./lib/tick.js'); | ||
var bar = new SimpleTick('analyzing dependencies '); | ||
return collector(components) | ||
.then(function(components) { | ||
bar.clear(); | ||
return components; | ||
}); | ||
}) | ||
.then(function(components) { | ||
@@ -168,3 +181,3 @@ | ||
var progress = function(percent, loaded, total) { | ||
if (false && total) { | ||
if (total) { | ||
bar = bar || new ProgressBar('downloading `' + component.address + '` [:bar] :percent :etas', { | ||
@@ -171,0 +184,0 @@ complete: '=', |
@@ -0,9 +1,15 @@ | ||
var lastInstance; | ||
var SimpleTick = module.exports = function SimpleTick(prefix, options) { | ||
this.options = options = options || {}; | ||
lastInstance && (lastInstance.clear() && (lastInstance = null)) | ||
this.options = options = options || {keepAlive: true}; | ||
this.stream = options.stream || process.stderr; | ||
this.prefix = prefix; | ||
this.tokens = options.tokens || ['↑', '↗', '→', '↘', '↓', '↙', '←', '↖']; | ||
this.tokens = options.tokens || '|/-\\'.split(''); | ||
this.count = 0; | ||
this.render(); | ||
this.tick(); | ||
this.timer = null; | ||
lastInstance = this; | ||
}; | ||
@@ -25,9 +31,16 @@ | ||
SimpleTick.prototype.tick = function() { | ||
this.render(); | ||
this.count++; | ||
this.render(); | ||
if (this.options.keepAlive) { | ||
clearTimeout(this.timer); | ||
this.timer = setTimeout(this.tick.bind(this), this.options.interval || 300); | ||
} | ||
}; | ||
SimpleTick.prototype.clear = function() { | ||
clearTimeout(this.timer); | ||
lastInstance = null; | ||
this.stream.clearLine(); | ||
this.stream.cursorTo(0); | ||
} |
{ | ||
"name": "fis-command-install", | ||
"description": "fis install command.", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"author": "FIS Team <fis@baidu.com>", | ||
@@ -6,0 +6,0 @@ "homepage": "http://fis.baidu.com/", |
42457
966