From 77fb081b9304064ceac244fa1eeab681ecc392d3 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Fri, 5 Oct 2012 13:53:06 +0200 Subject: [PATCH] Make it possible to disable colors Fixes #76 --- README.md | 2 ++ lib/util/hogan-colors.js | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index cd07d96f..1a8f3183 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,8 @@ To search for packages: To list all the available packages, just call `bower search` without specifying a name. +You can disable colors by using the `--no-color` flag. + ### Defining a package You can create a `component.json` file in your project's root, specifying all of its dependencies. This is similar to Node's `package.json`, or Ruby's `Gemfile`, and is useful for locking down a project's dependencies. diff --git a/lib/util/hogan-colors.js b/lib/util/hogan-colors.js index 19551f08..65d8f0bb 100644 --- a/lib/util/hogan-colors.js +++ b/lib/util/hogan-colors.js @@ -9,8 +9,13 @@ var colors = require('colors'); var hogan = require('hogan.js'); var _ = require('lodash'); +var nopt = require('nopt'); module.exports = hogan.Template.prototype.renderWithColors = function (context, partials, indent) { + if (nopt(process.argv).color === false) { + colors.mode = 'none'; + } + context = _.extend({ yellow : function (s) { return s.yellow }, green : function (s) { return s.green },