From fb5028eb90777dc526bb83c0d64b23549ec3909e Mon Sep 17 00:00:00 2001 From: David Majda Date: Sat, 7 Jan 2012 12:01:11 +0100 Subject: [PATCH] Use |util| module instead of |sys| |sys| emits a warning in Node.js 0.6.x. --- Jakefile | 4 ++-- benchmark/run | 28 ++++++++++++++-------------- bin/pegjs | 38 +++++++++++++++++++------------------- test/run | 20 ++++++++++---------- 4 files changed, 45 insertions(+), 45 deletions(-) diff --git a/Jakefile b/Jakefile index 5bc5a1d..7231a7e 100644 --- a/Jakefile +++ b/Jakefile @@ -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(); } diff --git a/benchmark/run b/benchmark/run index c51e8b3..254915c 100755 --- a/benchmark/run +++ b/benchmark/run @@ -1,8 +1,8 @@ #!/usr/bin/env node -var sys = require("sys"); -var fs = require("fs"); -var PEG = require("../lib/peg"); +var util = require("util"); +var fs = require("fs"); +var PEG = require("../lib/peg"); [ "benchmarks.js", @@ -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) { diff --git a/bin/pegjs b/bin/pegjs index 46694e5..08ca376 100755 --- a/bin/pegjs +++ b/bin/pegjs @@ -1,30 +1,30 @@ #!/usr/bin/env node -var sys = require("sys"); -var fs = require("fs"); -var PEG = require("../lib/peg"); +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] [--] [] []"); - sys.puts(""); - sys.puts("Generates a parser from the PEG grammar specified in the and"); - sys.puts("writes it to the ."); - sys.puts(""); - sys.puts("If the is omitted, its name is generated by changing the"); - sys.puts(" extension to \".js\". If both and are"); - sys.puts("omitted, standard input and output are used."); - sys.puts(""); - sys.puts("Options:"); - sys.puts(" -e, --export-var 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] [--] [] []"); + util.puts(""); + util.puts("Generates a parser from the PEG grammar specified in the and"); + util.puts("writes it to the ."); + util.puts(""); + util.puts("If the is omitted, its name is generated by changing the"); + util.puts(" extension to \".js\". If both and are"); + util.puts("omitted, standard input and output are used."); + util.puts(""); + util.puts("Options:"); + util.puts(" -e, --export-var 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(); } diff --git a/test/run b/test/run index 551aa3c..98192a8 100755 --- a/test/run +++ b/test/run @@ -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)" )