Commit 0e147d3d 0e147d3d2af6c0aec72e9dc14896cc66a707ddcf by renatodarrigo

Update colorizer.js to check for ANSICON and have colors on Windows

Check env variable 'ANSICON', and if exists, colorize the output.
1 parent 56dce225
......@@ -33,6 +33,7 @@
var require = patchRequire(require);
var fs = require('fs');
var utils = require('utils');
var env = require('system').env;
exports.create = function create(type) {
"use strict";
......@@ -79,7 +80,7 @@ var Colorizer = function Colorizer() {
* @return String
*/
this.colorize = function colorize(text, styleName, pad) {
if (fs.isWindows() || !(styleName in styles)) {
if ((fs.isWindows() && env['ANSICON'] == null) || !(styleName in styles)) {
return text;
}
return this.format(text, styles[styleName], pad);
......@@ -93,7 +94,7 @@ var Colorizer = function Colorizer() {
* @return String
*/
this.format = function format(text, style, pad) {
if (fs.isWindows() || !utils.isObject(style)) {
if ((fs.isWindows() && env['ANSICON'] == null) || !utils.isObject(style)) {
return text;
}
var codes = [];
......