Added checking on process.stdout to be compatible with browserify

This commit is contained in:
Matthieu Bulté 2015-03-08 14:40:27 +01:00
parent a548b70e8c
commit 3548b4883e
2 changed files with 4 additions and 4 deletions

View File

@ -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";
};

View File

@ -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"