diff --git a/CHANGELOG.md b/CHANGELOG.md index 770433da..dbff4797 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * When installing a Titanium SDK using the CI version name, but omitting the branch, it now automatically scans all branches [TIMOB-15899] * Fixed 'sdk' command to display custom Titanium SDK paths in SDK Install Locations [TIMOB-16141] * Fixed bug where the password was not being discarded after logging in and ends up confusing the Android build [TIMOB-16422] + * Fixed disabling of colors for 'setup' command. Also fixed --no-color flag [TIMOB-16853] 3.2.2 ------------------- diff --git a/lib/commands/setup.js b/lib/commands/setup.js index 0180829b..ed618074 100644 --- a/lib/commands/setup.js +++ b/lib/commands/setup.js @@ -43,6 +43,8 @@ exports.extendedDesc = __f('commands/setup'); * @returns {Object} Setup command configuration */ exports.config = function (logger, config, cli) { + fields.setup({ colors: cli.argv.colors }); + return { noAuth: true, args: [ @@ -68,10 +70,6 @@ exports.config = function (logger, config, cli) { exports.run = function (logger, config, cli, finished) { logger.log(__('Enter %s at any time to quit.', 'ctrl-c'.cyan)); - fields.setup({ - colors: !!config.get('cli.colors') - }); - var screens = new SetupScreens(logger, config, cli); var queue = async.queue(function (screen, callback) { diff --git a/lib/titanium.js b/lib/titanium.js index 094a6106..db7ac967 100644 --- a/lib/titanium.js +++ b/lib/titanium.js @@ -208,13 +208,20 @@ function run(locale) { }, 'colors': { callback: function (value) { - var c = value !== false; + var c = process.stdout.isTTY ? value !== false : false; colors.mode = c ? 'console' : 'none'; Object.keys(logger.transports).forEach(function (name) { logger.transports[name].colorize = c; }); + if (!value) { + // since this function is called whenever --no-color or --no-colors is set + // and we don't know which one it was, we set whichever is not set and the + // parser will correctly set --no-colors + cli.argv.$_.indexOf('--no-color') == -1 && cli.argv.$_.push('--no-color'); + cli.argv.$_.indexOf('--no-colors') == -1 && cli.argv.$_.push('--no-colors'); + } }, - default: config.get('cli.colors', true), + default: process.stdout.isTTY ? config.get('cli.colors', true) : false, desc: __('disable colors'), hideDefault: true, negate: true @@ -235,7 +242,7 @@ function run(locale) { negate: true }, 'progress-bars': { - default: config.get('cli.progressBars', true), + default: process.stdout.isTTY ? config.get('cli.progressBars', true) : false, desc: __('disable progress bars'), hideDefault: true, negate: true