mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
disabling colours for win32 and in presence of NODE_DISABLE_COLORS
environment variable
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user