Skip to content

Commit

Permalink
Merge pull request #1 from apgiorgi/apgiorgi-patch-1
Browse files Browse the repository at this point in the history
Added 'static-output' option to suppress progress bar
  • Loading branch information
apgiorgi committed Oct 19, 2015
2 parents c4a4214 + c8cf26c commit 361061e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions bin/firebase-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ var argv = require('optimist')
.describe('merge', 'Write the top-level children without overwriting the whole parent.')
.alias('m', 'merge')

.boolean('static-output')
.describe('static-output', 'Suppress progress bar for compatibility reasons.')
.alias('s', 'static-output')

.boolean('force')
.describe('force', 'Don\'t prompt before overwriting data.')

Expand Down Expand Up @@ -188,8 +192,11 @@ function chunkInternal(ref, json, forceSplit) {
function ChunkUploader(chunks) {
this.next = 0;
this.chunks = chunks;
this.bar = new ProgressBar('Importing [:bar] :percent (:current/:total)',
{ width: 50, total: chunks.length, incomplete: ' ' });
if (argv['static-output']) {
console.log('Importing... (may take a while)');
} else {
this.bar = new ProgressBar('Importing [:bar] :percent (:current/:total)', { width: 50, total: chunks.length, incomplete: ' ' });
}
}

ChunkUploader.prototype.go = function(onComplete) {
Expand All @@ -213,7 +220,9 @@ ChunkUploader.prototype.uploadNext = function() {
throw error;
}

self.bar.tick();
if (!argv['static-output']) {
self.bar.tick();
}

if (chunkNum === self.chunks.length - 1) {
self.onComplete();
Expand Down

0 comments on commit 361061e

Please sign in to comment.