Permalink
Browse files

[fix] Do not use `util.{print,puts}`

  • Loading branch information...
1 parent fb0ec87 commit bc4c23929f3ce4ba66650130675405a1e85bb26c @mmalecki mmalecki committed Jun 14, 2013
View
@@ -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 {
@@ -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") }
@@ -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)) : '')
View
@@ -15,8 +15,7 @@
// }
// }).run();
//
-var util = require('util'),
- path = require('path'),
+var path = require('path'),
events = require('events'),
vows = exports;
@@ -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', {
@@ -201,7 +200,7 @@ process.on('exit', function () {
});
});
if (failure) {
- util.puts(console.result(results));
+ console.log(console.result(results));
process.exit(1);
}
});
@@ -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;
}
@@ -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;
}
};
@@ -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();
}
}
};
@@ -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'));
@@ -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.