Skip to content

Commit

Permalink
Added 'static-output' option to suppress progress bar for compatibili…
Browse files Browse the repository at this point in the history
…ty reasons.

The progress bar module will crash when firebase-import is run from cron or piping the stdout. Also, in some cases the progress bar "animation" can be annoying.
  • Loading branch information
apgiorgi committed Oct 19, 2015
1 parent c4a4214 commit c8cf26c
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 c8cf26c

Please sign in to comment.