disabling colours for win32 and in presence of NODE_DISABLE_COLORS

environment variable
This commit is contained in:
Michael Ficarra
2011-04-05 20:51:28 -04:00
parent 68c75c7eb1
commit 8e7c454de0
2 changed files with 12 additions and 3 deletions

View File

@@ -1,10 +1,14 @@
(function() {
var ACCESSOR, CoffeeScript, SIMPLEVAR, Script, autocomplete, backlog, completeAttribute, completeVariable, error, getCompletions, getPropertyNames, inspect, readline, repl, run, stdin, stdout;
var ACCESSOR, CoffeeScript, SIMPLEVAR, Script, autocomplete, backlog, completeAttribute, completeVariable, enableColours, error, getCompletions, getPropertyNames, inspect, readline, repl, run, stdin, stdout;
var __hasProp = Object.prototype.hasOwnProperty;
CoffeeScript = require('./coffee-script');
readline = require('readline');
inspect = require('util').inspect;
Script = process.binding('evals').Script;
enableColours = false;
if (process.platform !== 'win32') {
enableColours = !process.env.NODE_DISABLE_COLORS;
}
stdin = process.openStdin();
stdout = process.stdout;
error = function(err) {
@@ -25,7 +29,7 @@
filename: 'repl'
});
if (val !== void 0) {
process.stdout.write(inspect(val, false, 2, true) + '\n');
process.stdout.write(inspect(val, false, 2, enableColours) + '\n');
}
} catch (err) {
error(err);

View File

@@ -12,6 +12,11 @@ Script = process.binding('evals').Script
# REPL Setup
# Config
enableColours = no
if process.platform isnt 'win32'
enableColours = !process.env.NODE_DISABLE_COLORS
# Start by opening up `stdin` and `stdout`.
stdin = process.openStdin()
stdout = process.stdout
@@ -33,7 +38,7 @@ run = (buffer) ->
backlog = ''
try
val = CoffeeScript.eval code, bare: on, globals: on, filename: 'repl'
process.stdout.write inspect(val, no, 2, yes) + '\n' if val isnt undefined
process.stdout.write inspect(val, no, 2, enableColours) + '\n' if val isnt undefined
catch err
error err
repl.prompt()