Skip to content

Commit

Permalink
Merge pull request #1469 from dasilvacontin/issue/1461
Browse files Browse the repository at this point in the history
fixes #1461: nyan-reporter now respects Base.useColors, fixed bug in Base.color
  • Loading branch information
Travis Jeffery committed Dec 15, 2014
2 parents 688e70c + e57ea6b commit 8b17dbf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/reporters/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ if ('win32' == process.platform) {
*/

var color = exports.color = function(type, str) {
if (!exports.useColors) return str;
if (!exports.useColors) return String(str);
return '\u001b[' + exports.colors[type] + 'm' + str + '\u001b[0m';
};

Expand Down
26 changes: 13 additions & 13 deletions lib/reporters/nyan.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
* Module dependencies.
*/

var Base = require('./base')
, color = Base.color;
var Base = require('./base');

/**
* Expose `Dot`.
Expand Down Expand Up @@ -80,17 +79,16 @@ NyanCat.prototype.draw = function(){

NyanCat.prototype.drawScoreboard = function(){
var stats = this.stats;
var colors = Base.colors;

function draw(color, n) {
function draw(type, n) {
write(' ');
write('\u001b[' + color + 'm' + n + '\u001b[0m');
write(Base.color(type, n));
write('\n');
}

draw(colors.green, stats.passes);
draw(colors.fail, stats.failures);
draw(colors.pending, stats.pending);
draw('green', stats.passes);
draw('fail', stats.failures);
draw('pending', stats.pending);
write('\n');

this.cursorUp(this.numberOfLines);
Expand Down Expand Up @@ -140,26 +138,26 @@ NyanCat.prototype.drawRainbow = function(){
NyanCat.prototype.drawNyanCat = function() {
var self = this;
var startWidth = this.scoreboardWidth + this.trajectories[0].length;
var color = '\u001b[' + startWidth + 'C';
var dist = '\u001b[' + startWidth + 'C';
var padding = '';

write(color);
write(dist);
write('_,------,');
write('\n');

write(color);
write(dist);
padding = self.tick ? ' ' : ' ';
write('_|' + padding + '/\\_/\\ ');
write('\n');

write(color);
write(dist);
padding = self.tick ? '_' : '__';
var tail = self.tick ? '~' : '^';
var face;
write(tail + '|' + padding + this.face() + ' ');
write('\n');

write(color);
write(dist);
padding = self.tick ? ' ' : ' ';
write(padding + '"" "" ');
write('\n');
Expand Down Expand Up @@ -240,6 +238,8 @@ NyanCat.prototype.generateColors = function(){
*/

NyanCat.prototype.rainbowify = function(str){
if (!Base.useColors)
return str;
var color = this.rainbowColors[this.colorIndex % this.rainbowColors.length];
this.colorIndex += 1;
return '\u001b[38;5;' + color + 'm' + str + '\u001b[0m';
Expand Down

0 comments on commit 8b17dbf

Please sign in to comment.