Skip to content

Commit 969ee3d

Browse files
committed
Add flag to disable colors in REPL
1 parent 39a2a9d commit 969ee3d

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/repl.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ var fs = require("fs");
2020
var rl = require('readline');
2121
var context;
2222

23+
var disableColors = process.env.NODE_DISABLE_COLORS ? true : false;
24+
2325
function cwdRequire (id) {
2426
if (id.match(/^\.\.\//) || id.match(/^\.\//)) {
2527
id = path.join(process.cwd(), id);
@@ -54,7 +56,7 @@ function REPLServer(prompt, stream) {
5456
return self.complete(text);
5557
});
5658

57-
if (rli.enabled) {
59+
if (rli.enabled && !disableColors) {
5860
// Turn on ANSI coloring.
5961
exports.writer = function(obj, showHidden, depth) {
6062
return sys.inspect(obj, showHidden, depth, true);

src/node.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,6 +1746,7 @@ static void PrintHelp() {
17461746
"NODE_DEBUG Print additional debugging output.\n"
17471747
"NODE_MODULE_CONTEXTS Set to 1 to load modules in their own\n"
17481748
" global contexts.\n"
1749+
"NODE_DISABLE_COLORS Set to 1 to disable colors in the REPL\n"
17491750
"\n"
17501751
"Documentation can be found at http://nodejs.org/api.html"
17511752
" or with 'man node'\n");

0 commit comments

Comments
 (0)