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 @@ ...@@ -33,6 +33,7 @@
33 var require = patchRequire(require); 33 var require = patchRequire(require);
34 var fs = require('fs'); 34 var fs = require('fs');
35 var utils = require('utils'); 35 var utils = require('utils');
36 var env = require('system').env;
36 37
37 exports.create = function create(type) { 38 exports.create = function create(type) {
38 "use strict"; 39 "use strict";
...@@ -79,7 +80,7 @@ var Colorizer = function Colorizer() { ...@@ -79,7 +80,7 @@ var Colorizer = function Colorizer() {
79 * @return String 80 * @return String
80 */ 81 */
81 this.colorize = function colorize(text, styleName, pad) { 82 this.colorize = function colorize(text, styleName, pad) {
82 if (fs.isWindows() || !(styleName in styles)) { 83 if ((fs.isWindows() && env['ANSICON'] == null) || !(styleName in styles)) {
83 return text; 84 return text;
84 } 85 }
85 return this.format(text, styles[styleName], pad); 86 return this.format(text, styles[styleName], pad);
...@@ -93,7 +94,7 @@ var Colorizer = function Colorizer() { ...@@ -93,7 +94,7 @@ var Colorizer = function Colorizer() {
93 * @return String 94 * @return String
94 */ 95 */
95 this.format = function format(text, style, pad) { 96 this.format = function format(text, style, pad) {
96 if (fs.isWindows() || !utils.isObject(style)) { 97 if ((fs.isWindows() && env['ANSICON'] == null) || !utils.isObject(style)) {
97 return text; 98 return text;
98 } 99 }
99 var codes = []; 100 var codes = [];
......