diff --git a/commands/login.js b/commands/login.js index b203470ed3f..2201da95c07 100644 --- a/commands/login.js +++ b/commands/login.js @@ -18,7 +18,7 @@ var ticketsRef = new Firebase(utils.addSubdomain(api.realtimeOrigin, 'firebase') module.exports = new Command('login') .description('sign into Firebase') .action(function(options) { - if (utils.getInheritedOption(options, 'nonInteractive')) { + if (options.nonInteractive) { return utils.reject('Cannot run login in non-interactive mode. Pass ' + chalk.bold('--token') + ' instead.', {exit: 1}); } diff --git a/lib/command.js b/lib/command.js index 75e13e640f7..961561c7baf 100644 --- a/lib/command.js +++ b/lib/command.js @@ -94,7 +94,7 @@ Command.prototype.register = function(client) { }; Command.prototype._prepare = function(options) { - if (!process.stdin.isTTY) { + if (!process.stdin.isTTY || utils.getInheritedOption(options, 'nonInteractive')) { options.nonInteractive = true; } if (utils.getInheritedOption(options, 'debug')) { diff --git a/lib/deploy/hosting/deploy.js b/lib/deploy/hosting/deploy.js index 7824d89b731..60e78bcdd4d 100644 --- a/lib/deploy/hosting/deploy.js +++ b/lib/deploy/hosting/deploy.js @@ -32,26 +32,41 @@ module.exports = function(context, options, payload) { return new RSVP.Promise(function(resolve, reject) { var lastCount = 0; - - var bar = new ProgressBar(chalk.bold('Uploading:') + ' [:bar] :percent', { - total: upload.manifest.length, - width: 40, - complete: chalk.green('='), - incomplete: ' ', - clear: true - }); + var lastPercent = 0; + var bar; + if (!options.nonInteractive && process.stderr) { + bar = new ProgressBar(chalk.bold('Uploading:') + ' [:bar] :percent', { + total: upload.manifest.length, + width: 40, + complete: chalk.green('='), + incomplete: ' ', + clear: true + }); + } else { + process.stdout.write(chalk.cyan.bold('\ni') + chalk.bold(' Progress: [')); + } local.versionRef.on('value', function(snap) { var status = snap.child('status').val(); switch (status) { case 'deploying': var uc = snap.child('uploadedCount').val() || 0; - bar.tick(uc - lastCount); + var percent = Math.round(100.0 * uc / upload.manifest.length); + if (bar) { + bar.tick(uc - lastCount); + } else { + process.stdout.write(_.repeat(chalk.green('.'), percent - lastPercent)); + lastPercent = percent; + } lastCount = uc; break; case 'deployed': + if (bar) { + bar.terminate(); + } else { + process.stdout.write(chalk.bold(']') + '\n\n'); + } utils.logSuccess(upload.manifest.length + ' files uploaded successfully'); - bar.terminate(); local.versionRef.off('value'); resolve(); break; diff --git a/lib/prompt.js b/lib/prompt.js index c769ad447c5..414a01fec28 100644 --- a/lib/prompt.js +++ b/lib/prompt.js @@ -4,7 +4,6 @@ var inquirer = require('inquirer'); var _ = require('lodash'); var FirebaseError = require('./error'); var RSVP = require('rsvp'); -var utils = require('./utils'); module.exports = function(options, questions) { return new RSVP.Promise(function(resolve, reject) { @@ -15,7 +14,7 @@ module.exports = function(options, questions) { } } - if (prompts.length && utils.getInheritedOption(options, 'nonInteractive')) { + if (prompts.length && options.nonInteractive) { return reject(new FirebaseError('Missing required options (' + _.uniq(_.pluck(prompts, 'name')).join(', ') + ') while running in non-interactive mode', { children: prompts, exit: 1