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 fs = require("fs");
var path = require("path"); var path = require("path");
var childProcess = require("child_process"); var childProcess = require("child_process");
@ -53,7 +53,7 @@ function exitFailure() {
} }
function abort(message) { function abort(message) {
sys.error(message); util.error(message);
exitFailure(); exitFailure();
} }

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

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

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

Loading…
Cancel
Save