Skip to content

Commit

Permalink
check tty too
Browse files Browse the repository at this point in the history
  • Loading branch information
cmbuckley committed Oct 24, 2012
1 parent 3d41c2e commit d0f1925
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tinycolor.js
@@ -1,3 +1,5 @@
var tty = require('tty');

var styles = {
'bold': ['\033[1m', '\033[22m'],
'italic': ['\033[3m', '\033[23m'],
Expand All @@ -24,7 +26,7 @@ var styles = {
'bgDefault': ['\033[49m', '\033[49m']
}

var enabled = !process.env.NOCOLOR;
var enabled = !process.env.NOCOLOR && tty.isatty(1) && tty.isatty(2);

Object.keys(styles).forEach(function(style) {
Object.defineProperty(String.prototype, style, {
Expand Down

0 comments on commit d0f1925

Please sign in to comment.