From 783f5019b0fe03cb03c494f7cc5d21d01e03b723 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sat, 9 Oct 2010 12:46:06 -0700 Subject: [PATCH] Add flag to disable colors in REPL --- lib/repl.js | 4 +++- src/node.cc | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/repl.js b/lib/repl.js index fcd65e0ca6..ce231ef82f 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -20,6 +20,8 @@ var fs = require("fs"); var rl = require('readline'); var context; +var disableColors = process.env.NODE_DISABLE_COLORS ? true : false; + function cwdRequire (id) { if (id.match(/^\.\.\//) || id.match(/^\.\//)) { id = path.join(process.cwd(), id); @@ -54,7 +56,7 @@ function REPLServer(prompt, stream) { return self.complete(text); }); - if (rli.enabled) { + if (rli.enabled && !disableColors) { // Turn on ANSI coloring. exports.writer = function(obj, showHidden, depth) { return sys.inspect(obj, showHidden, depth, true); diff --git a/src/node.cc b/src/node.cc index 36913eeadf..7a76fbd81e 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1733,6 +1733,7 @@ static void PrintHelp() { "NODE_DEBUG Print additional debugging output.\n" "NODE_MODULE_CONTEXTS Set to 1 to load modules in their own\n" " global contexts.\n" + "NODE_DISABLE_COLORS Set to 1 to disable colors in the REPL\n" "\n" "Documentation can be found at http://nodejs.org/api.html" " or with 'man node'\n");