Export disableColors from repl, share with debugger
authorFedor Indutny <fedor.indutny@gmail.com>
Tue, 27 Sep 2011 09:57:30 +0000 (11:57 +0200)
committerBert Belder <bertbelder@gmail.com>
Tue, 27 Sep 2011 09:58:02 +0000 (11:58 +0200)
lib/_debugger.js
lib/repl.js

index c380391..baec929 100644 (file)
@@ -670,7 +670,7 @@ function SourceUnderline(sourceText, position, tty) {
       tail = sourceText.slice(position);
 
   // Colourize char if stdout supports colours
-  if (tty) {
+  if (tty && !repl.disableColors) {
     tail = tail.replace(/(.+?)([^\w]|$)/, '\033[32m$1\033[39m$2');
   }
 
index 915afcd..23188e2 100644 (file)
@@ -56,9 +56,9 @@ function hasOwnProperty(obj, prop) {
 
 var context;
 
-var disableColors = true;
+exports.disableColors = true;
 if (process.platform != 'win32') {
-  disableColors = process.env.NODE_DISABLE_COLORS ? true : false;
+  exports.disableColors = process.env.NODE_DISABLE_COLORS ? true : false;
 }
 
 
@@ -114,7 +114,7 @@ function REPLServer(prompt, stream, eval) {
   this.commands = {};
   defineDefaultCommands(this);
 
-  if (rli.enabled && !disableColors && exports.writer === util.inspect) {
+  if (rli.enabled && !exports.disableColors && exports.writer === util.inspect) {
     // Turn on ANSI coloring.
     exports.writer = function(obj, showHidden, depth) {
       return util.inspect(obj, showHidden, depth, true);