Use |util| module instead of |sys|

|sys| emits a warning in Node.js 0.6.x.
redux
David Majda 12 years ago
parent fa1523b651
commit fb5028eb90

@ -1,4 +1,4 @@
var sys = require("sys");
var util = require("util");
var fs = require("fs");
var path = require("path");
var childProcess = require("child_process");
@ -53,7 +53,7 @@ function exitFailure() {
}
function abort(message) {
sys.error(message);
util.error(message);
exitFailure();
}

@ -1,6 +1,6 @@
#!/usr/bin/env node
var sys = require("sys");
var util = require("util");
var fs = require("fs");
var PEG = require("../lib/peg");
@ -37,21 +37,21 @@ function center(text, length) {
}
function writeTableHeader() {
sys.puts("┌─────────────────────────────────────┬───────────┬────────────┬──────────────┐");
sys.puts("│ Test │ Inp. size │ Avg. time │ Avg. speed │");
util.puts("┌─────────────────────────────────────┬───────────┬────────────┬──────────────┐");
util.puts("│ Test │ Inp. size │ Avg. time │ Avg. speed │");
}
function writeHeading(heading) {
sys.puts("├─────────────────────────────────────┴───────────┴────────────┴──────────────┤");
sys.puts("│ " + center(heading, 75) + " │");
sys.puts("├─────────────────────────────────────┬───────────┬────────────┬──────────────┤");
util.puts("├─────────────────────────────────────┴───────────┴────────────┴──────────────┤");
util.puts("│ " + center(heading, 75) + " │");
util.puts("├─────────────────────────────────────┬───────────┬────────────┬──────────────┤");
}
function writeResult(title, inputSize, parseTime) {
var KB = 1024;
var MS_IN_S = 1000;
sys.puts("│ "
util.puts("│ "
+ padRight(title, 35)
+ " │ "
+ padLeft((inputSize / KB).toFixed(2), 6)
@ -64,11 +64,11 @@ function writeResult(title, inputSize, parseTime) {
}
function writeSeparator() {
sys.puts("├─────────────────────────────────────┼───────────┼────────────┼──────────────┤");
util.puts("├─────────────────────────────────────┼───────────┼────────────┼──────────────┤");
}
function writeTableFooter() {
sys.puts("└─────────────────────────────────────┴───────────┴────────────┴──────────────┘");
util.puts("└─────────────────────────────────────┴───────────┴────────────┴──────────────┘");
}
/* Helpers */
@ -78,7 +78,7 @@ function exitFailure() {
}
function abort(message) {
sys.error(message);
util.error(message);
exitFailure();
}
@ -100,8 +100,8 @@ switch (args.length) {
abort("Too many arguments.");
}
sys.puts("Each test is run " + runCount + " times.");
sys.puts("");
util.puts("Each test is run " + runCount + " times.");
util.puts("");
Runner.run(benchmarks, runCount, {
readFile: function(file) {

@ -1,30 +1,30 @@
#!/usr/bin/env node
var sys = require("sys");
var util = require("util");
var fs = require("fs");
var PEG = require("../lib/peg");
/* Helpers */
function printVersion() {
sys.puts("PEG.js " + PEG.VERSION);
util.puts("PEG.js " + PEG.VERSION);
}
function printHelp() {
sys.puts("Usage: pegjs [options] [--] [<input_file>] [<output_file>]");
sys.puts("");
sys.puts("Generates a parser from the PEG grammar specified in the <input_file> and");
sys.puts("writes it to the <output_file>.");
sys.puts("");
sys.puts("If the <output_file> is omitted, its name is generated by changing the");
sys.puts("<input_file> extension to \".js\". If both <input_file> and <output_file> are");
sys.puts("omitted, standard input and output are used.");
sys.puts("");
sys.puts("Options:");
sys.puts(" -e, --export-var <variable> name of the variable where the parser object");
sys.puts(" will be stored (default: \"module.exports\")");
sys.puts(" -v, --version print version information and exit");
sys.puts(" -h, --help print help and exit");
util.puts("Usage: pegjs [options] [--] [<input_file>] [<output_file>]");
util.puts("");
util.puts("Generates a parser from the PEG grammar specified in the <input_file> and");
util.puts("writes it to the <output_file>.");
util.puts("");
util.puts("If the <output_file> is omitted, its name is generated by changing the");
util.puts("<input_file> extension to \".js\". If both <input_file> and <output_file> are");
util.puts("omitted, standard input and output are used.");
util.puts("");
util.puts("Options:");
util.puts(" -e, --export-var <variable> name of the variable where the parser object");
util.puts(" will be stored (default: \"module.exports\")");
util.puts(" -v, --version print version information and exit");
util.puts(" -h, --help print help and exit");
}
function exitSuccess() {
@ -36,7 +36,7 @@ function exitFailure() {
}
function abort(message) {
sys.error(message);
util.error(message);
exitFailure();
}

@ -1,6 +1,6 @@
#!/usr/bin/env node
var sys = require("sys");
var util = require("util");
var fs = require("fs");
var PEG = require("../lib/peg");
var QUnit = require("./vendor/qunit/qunit").QUnit;
@ -19,8 +19,8 @@ QUnit.config.blocking = true;
QUnit.config.updateRate = 0;
QUnit.moduleStart = function(details) {
sys.puts("");
sys.puts(bold(details.name));
util.puts("");
util.puts(bold(details.name));
};
var failedAssertions = [];
@ -31,12 +31,12 @@ QUnit.testStart = function(details) {
QUnit.testDone = function(details) {
if (details.failed == 0) {
sys.puts('✔ ' + details.name);
util.puts('✔ ' + details.name);
} else {
sys.puts(error('✖ ' + details.name));
sys.puts("");
util.puts(error('✖ ' + details.name));
util.puts("");
failedAssertions.forEach(function(assertion) {
sys.puts(assertion);
util.puts(assertion);
});
}
};
@ -59,15 +59,15 @@ QUnit.log = function(details) {
};
QUnit.done = function(details) {
sys.puts("");
util.puts("");
if (details.failed > 0) {
sys.puts(bold(error("FAILURES: "))
util.puts(bold(error("FAILURES: "))
+ details.failed + "/"
+ details.total + " assertions failed ("
+ details.runtime + " ms)"
);
} else {
sys.puts(bold(ok('OK: '))
util.puts(bold(ok('OK: '))
+ details.total + " assertions ("
+ details.runtime + " ms)"
)

Loading…
Cancel
Save