diff --git a/lib/logger.js b/lib/logger.js index 161ef7b9b..be18e5324 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -43,9 +43,12 @@ Logger.prototype.log = function (type, libName, err, libSource) { var message = makeMsg(err) - if (this.last == 'progress') - process.stdout.write('\033[1F\033[0K') if (type !== SUCCESS || this.verbose) { + if (this.last == 'progress') { + process.stdout.cursorTo(0) + process.stdout.write('\033[1F\033[0K') + process.stdout.clearLine(1) + } process.stdout.write( strings.rpad((type.toUpperCase() + ':'), 8)[type === ERROR ? 'red' : type === WARNING ? 'yellow' : 'green'] + ' ' + strings.rpad(libName || 'UNKNOWN LIBRARY', 20).bold @@ -54,8 +57,8 @@ Logger.prototype.log = function (type, libName, err, libSource) { ) if (libSource) console.log(strings.lpad('', 8), Array.isArray(libSource) ? libSource.join(', ') : libSource) + this.last = 'log' } - this.last = 'log' } Logger.prototype.progress = function (completed, total) { @@ -70,9 +73,13 @@ Logger.prototype.progress = function (completed, total) { , PROGRESS_BAR_LENGTH) + '| ' + perc + '%' // (' + completed + '/' + total + ')' - if (this.last == 'progress') - process.stdout.write('\033[1F\033[0K') - console.log(ps.green.bold) + if (this.last == 'progress') { + process.stdout.cursorTo(0) + process.stdout.write(ps.green.bold) + process.stdout.clearLine(1) + } else { + process.stdout.write(ps.green.bold) + } this.last = 'progress' }