Skip to content

Commit

Permalink
[fix] Do not use util.{print,puts}
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalecki committed Jun 14, 2013
1 parent fb0ec87 commit bc4c239
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
7 changes: 4 additions & 3 deletions bin/vows
Expand Up @@ -295,7 +295,7 @@ if (! options.watch) {
msg('runner', 'finish');
_reporter.report(['finish', results], {
write: function (str) {
util.print(str.replace(/^\n\n/, '\n'));
process.stdout.write(str.replace(/^\n\n/, '\n'));
}
});
try {
Expand Down Expand Up @@ -364,7 +364,7 @@ if (! options.watch) {
//
// Utility functions
//
function print(str) { util.print(str) }
function print(str) { process.stdout.write(str) }
function esc(str) { print("\x1b[" + str) }
function eraseLine() { esc("0K") }
function cursorRestore() { esc("0G") }
Expand Down Expand Up @@ -613,7 +613,8 @@ function paths(dir) {

function msg(cmd, subject, str, p) {
if (options.verbose) {
util[p ? 'print' : 'puts']( stylize('vows ', 'green')
var func = p ? process.stdout.write.bind(process.stdout) : console.log;
func( stylize('vows ', 'green')
+ stylize(cmd, 'bold')
+ ' ' + subject + ' '
+ (str ? (typeof(str) === 'string' ? str : inspect(str)) : '')
Expand Down
7 changes: 3 additions & 4 deletions lib/vows.js
Expand Up @@ -15,8 +15,7 @@
// }
// }).run();
//
var util = require('util'),
path = require('path'),
var path = require('path'),
events = require('events'),
vows = exports;

Expand Down Expand Up @@ -181,7 +180,7 @@ process.on('exit', function () {
}
});

if (unFired.length > 0) { util.print('\n') }
if (unFired.length > 0) { console.log(); }

unFired.forEach(function (title) {
s.reporter.report(['error', {
Expand All @@ -201,7 +200,7 @@ process.on('exit', function () {
});
});
if (failure) {
util.puts(console.result(results));
console.log(console.result(results));
process.exit(1);
}
});
Expand Down
2 changes: 1 addition & 1 deletion lib/vows/coverage/report-html.js
Expand Up @@ -53,7 +53,7 @@ this.report = function (coverageMap) {
head = fs.readFileSync(__dirname + "/fragments/coverage-head.html", "utf8");
foot = fs.readFileSync(__dirname + "/fragments/coverage-foot.html", "utf8");
} catch (error) {
util.print("Error: Unable to write to file coverage.html\n");
console.log("Error: Unable to write to file coverage.html");
return;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/vows/coverage/report-json.js
Expand Up @@ -48,7 +48,7 @@ this.report = function (coverageMap) {
fs.writeSync(out, JSON.stringify(output));
fs.close(out);
} catch (error) {
util.print("Error: Unable to write to file coverage.json\n");
console.log("Error: Unable to write to file coverage.json");
return;
}
};
10 changes: 5 additions & 5 deletions lib/vows/coverage/report-plain.js
Expand Up @@ -24,15 +24,15 @@ this.report = function (coverageMap) {
if (coverageMap.hasOwnProperty(filename)) {
var data = file.coverage(filename, coverageMap[filename]);

util.print(filename + ":\n");
util.print("[ hits: " + data.hits + ", misses: " + data.misses);
util.print(", sloc: " + data.sloc + ", coverage: " + data.coverage.toFixed(2) + "% ]\n");
console.log(filename + ":");
process.stdout.write("[ hits: " + data.hits + ", misses: " + data.misses);
console.log(", sloc: " + data.sloc + ", coverage: " + data.coverage.toFixed(2) + "% ]");

for (var i = 0; i < data.source.length; i++) {
util.print(lpad(data.source[i].coverage, 5) + " | " + data.source[i].line + "\n");
console.log(lpad(data.source[i].coverage, 5) + " | " + data.source[i].line);
}

util.print("\n");
console.log();
}
}
};
4 changes: 2 additions & 2 deletions lib/vows/reporters/spec.js
Expand Up @@ -26,7 +26,7 @@ this.report = function (data) {
puts(console.vowText(event));
break;
case 'end':
util.print('\n');
console.log();
break;
case 'finish':
puts(console.result(event).join('\n'));
Expand All @@ -38,5 +38,5 @@ this.report = function (data) {
};

this.print = function (str) {
util.print(str);
process.stdout.write(str);
};

0 comments on commit bc4c239

Please sign in to comment.