Skip to content

Commit

Permalink
Added --no-color option to suppress terminal colors
Browse files Browse the repository at this point in the history
  • Loading branch information
ashtuchkin authored and indexzero committed Nov 25, 2011
1 parent 8788a52 commit e92c1e4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
13 changes: 11 additions & 2 deletions bin/vows
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var help = [
" --cover-plain Print plain coverage map if detected",
" --cover-html Write coverage map to \"coverage.html\"",
" --cover-json Write unified coverage map to \"coverage.json\"",
//" --no-color Don't use terminal colors",
" --no-color Don't use terminal colors",
" --version Show version",
" -h, --help You're staring at it"
].join('\n');
Expand All @@ -69,7 +69,8 @@ var options = {
matcher: /.*/,
watch: false,
coverage: false,
isolate: false
isolate: false,
nocolor: !process.stdout.isTTY
};

var files = [];
Expand Down Expand Up @@ -151,6 +152,9 @@ while (arg = argv.shift()) {
case 'no-color':
options.nocolor = true;
break;
case 'color':
options.nocolor = false;
break;
case 'no-error':
options.error = false;
break;
Expand All @@ -167,6 +171,11 @@ while (arg = argv.shift()) {
}
}

if (options.nocolor) {
cutils.nocolor = true;
inspect = require('eyes').inspector({ stream: null, styles: false });
}

if (options.supressStdout) {
_reporter.setStream && _reporter.setStream(process.stdout);
var devNullStream = fs.createWriteStream('/dev/null');
Expand Down
5 changes: 5 additions & 0 deletions lib/vows/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ var eyes = require('eyes').inspector({ stream: null, styles: false });

// Stylize a string
this.stylize = function stylize(str, style) {
if (module.exports.nocolor)
return str;

var styles = {
'bold' : [1, 22],
'italic' : [3, 23],
Expand Down Expand Up @@ -85,6 +88,8 @@ this.result = function (event) {
};

this.inspect = function inspect(val) {
if (module.exports.nocolor)
return eyes(val);
return '\033[1m' + eyes(val) + '\033[22m';
};

Expand Down

0 comments on commit e92c1e4

Please sign in to comment.