diff --git a/lib/reporters/nyan.js b/lib/reporters/nyan.js index e7b3fa8f65..96de36591c 100644 --- a/lib/reporters/nyan.js +++ b/lib/reporters/nyan.js @@ -66,7 +66,7 @@ function NyanCat(runner, options) { runner.once(EVENT_RUN_END, function () { Base.cursor.show(); for (var i = 0; i < self.numberOfLines; i++) { - write('\n'); + process.stdout.write('\n'); } self.epilogue(); }); @@ -102,15 +102,15 @@ NyanCat.prototype.drawScoreboard = function () { var stats = this.stats; function draw(type, n) { - write(' '); - write(Base.color(type, n)); - write('\n'); + process.stdout.write(' '); + process.stdout.write(Base.color(type, n)); + process.stdout.write('\n'); } draw('green', stats.passes); draw('fail', stats.failures); draw('pending', stats.pending); - write('\n'); + process.stdout.write('\n'); this.cursorUp(this.numberOfLines); }; @@ -144,9 +144,9 @@ NyanCat.prototype.drawRainbow = function () { var self = this; this.trajectories.forEach(function (line) { - write('\u001b[' + self.scoreboardWidth + 'C'); - write(line.join('')); - write('\n'); + process.stdout.write('\u001b[' + self.scoreboardWidth + 'C'); + process.stdout.write(line.join('')); + process.stdout.write('\n'); }); this.cursorUp(this.numberOfLines); @@ -163,25 +163,25 @@ NyanCat.prototype.drawNyanCat = function () { var dist = '\u001b[' + startWidth + 'C'; var padding = ''; - write(dist); - write('_,------,'); - write('\n'); + process.stdout.write(dist); + process.stdout.write('_,------,'); + process.stdout.write('\n'); - write(dist); + process.stdout.write(dist); padding = self.tick ? ' ' : ' '; - write('_|' + padding + '/\\_/\\ '); - write('\n'); + process.stdout.write('_|' + padding + '/\\_/\\ '); + process.stdout.write('\n'); - write(dist); + process.stdout.write(dist); padding = self.tick ? '_' : '__'; var tail = self.tick ? '~' : '^'; - write(tail + '|' + padding + this.face() + ' '); - write('\n'); + process.stdout.write(tail + '|' + padding + this.face() + ' '); + process.stdout.write('\n'); - write(dist); + process.stdout.write(dist); padding = self.tick ? ' ' : ' '; - write(padding + '"" "" '); - write('\n'); + process.stdout.write(padding + '"" "" '); + process.stdout.write('\n'); this.cursorUp(this.numberOfLines); }; @@ -213,7 +213,7 @@ NyanCat.prototype.face = function () { */ NyanCat.prototype.cursorUp = function (n) { - write('\u001b[' + n + 'A'); + process.stdout.write('\u001b[' + n + 'A'); }; /** @@ -224,7 +224,7 @@ NyanCat.prototype.cursorUp = function (n) { */ NyanCat.prototype.cursorDown = function (n) { - write('\u001b[' + n + 'B'); + process.stdout.write('\u001b[' + n + 'B'); }; /** @@ -264,13 +264,4 @@ NyanCat.prototype.rainbowify = function (str) { return '\u001b[38;5;' + color + 'm' + str + '\u001b[0m'; }; -/** - * Stdout helper. - * - * @param {string} string A message to write to stdout. - */ -function write(string) { - process.stdout.write(string); -} - NyanCat.description = '"nyan cat"';