From 3548b4883e05a41ed6d39147f081999d5116e68d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthieu=20Bult=C3=A9?= Date: Sun, 8 Mar 2015 14:40:27 +0100 Subject: [PATCH] Added checking on process.stdout to be compatible with browserify --- lib/coffee-script/helpers.js | 6 +++--- src/helpers.coffee | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/coffee-script/helpers.js b/lib/coffee-script/helpers.js index e40f51b4..b5e25d1a 100644 --- a/lib/coffee-script/helpers.js +++ b/lib/coffee-script/helpers.js @@ -201,7 +201,7 @@ }; syntaxErrorToString = function() { - var codeLine, colorize, colorsEnabled, end, filename, first_column, first_line, last_column, last_line, marker, ref1, ref2, start; + var codeLine, colorize, colorsEnabled, end, filename, first_column, first_line, last_column, last_line, marker, ref1, ref2, ref3, ref4, start; if (!(this.code && this.location)) { return Error.prototype.toString.call(this); } @@ -218,9 +218,9 @@ end = first_line === last_line ? last_column + 1 : codeLine.length; marker = codeLine.slice(0, start).replace(/[^\s]/g, ' ') + repeat('^', end - start); if (typeof process !== "undefined" && process !== null) { - colorsEnabled = process.stdout.isTTY && !process.env.NODE_DISABLE_COLORS; + colorsEnabled = ((ref2 = process.stdout) != null ? ref2.isTTY : void 0) && !((ref3 = process.env) != null ? ref3.NODE_DISABLE_COLORS : void 0); } - if ((ref2 = this.colorful) != null ? ref2 : colorsEnabled) { + if ((ref4 = this.colorful) != null ? ref4 : colorsEnabled) { colorize = function(str) { return "\x1B[1;31m" + str + "\x1B[0m"; }; diff --git a/src/helpers.coffee b/src/helpers.coffee index 53f1bde2..cfa5547d 100644 --- a/src/helpers.coffee +++ b/src/helpers.coffee @@ -173,7 +173,7 @@ syntaxErrorToString = -> # Check to see if we're running on a color-enabled TTY. if process? - colorsEnabled = process.stdout.isTTY and not process.env.NODE_DISABLE_COLORS + colorsEnabled = process.stdout?.isTTY and not process.env?.NODE_DISABLE_COLORS if @colorful ? colorsEnabled colorize = (str) -> "\x1B[1;31m#{str}\x1B[0m"