Replace |util.{puts,error}| by |console.{log,error}|

The |util.puts| and |util.error| functions are deprecated in Node.js
0.12.x.

Based on a pull request by Jan Stránský (@burningtree):

  https://github.com/pegjs/pegjs/pull/334
redux
David Majda 9 years ago
parent 4b154e177f
commit de1704f007

@ -2,9 +2,8 @@
"use strict";
var util = require("util");
var fs = require("fs");
var PEG = require("../lib/peg");
var fs = require("fs");
var PEG = require("../lib/peg");
var benchmarks = require("./benchmarks.js");
var Runner = require("./runner.js")(PEG);
@ -35,21 +34,21 @@ function center(text, length) {
}
function writeTableHeader() {
util.puts("┌─────────────────────────────────────┬───────────┬────────────┬──────────────┐");
util.puts("│ Test │ Inp. size │ Avg. time │ Avg. speed │");
console.log("┌─────────────────────────────────────┬───────────┬────────────┬──────────────┐");
console.log("│ Test │ Inp. size │ Avg. time │ Avg. speed │");
}
function writeHeading(heading) {
util.puts("├─────────────────────────────────────┴───────────┴────────────┴──────────────┤");
util.puts("│ " + center(heading, 75) + " │");
util.puts("├─────────────────────────────────────┬───────────┬────────────┬──────────────┤");
console.log("├─────────────────────────────────────┴───────────┴────────────┴──────────────┤");
console.log("│ " + center(heading, 75) + " │");
console.log("├─────────────────────────────────────┬───────────┬────────────┬──────────────┤");
}
function writeResult(title, inputSize, parseTime) {
var KB = 1024;
var MS_IN_S = 1000;
util.puts("│ "
console.log("│ "
+ padRight(title, 35)
+ " │ "
+ padLeft((inputSize / KB).toFixed(2), 6)
@ -62,25 +61,25 @@ function writeResult(title, inputSize, parseTime) {
}
function writeSeparator() {
util.puts("├─────────────────────────────────────┼───────────┼────────────┼──────────────┤");
console.log("├─────────────────────────────────────┼───────────┼────────────┼──────────────┤");
}
function writeTableFooter() {
util.puts("└─────────────────────────────────────┴───────────┴────────────┴──────────────┘");
console.log("└─────────────────────────────────────┴───────────┴────────────┴──────────────┘");
}
/* Helpers */
function printHelp() {
util.puts("Usage: run [options]");
util.puts("");
util.puts("Runs PEG.js benchmark suite.");
util.puts("");
util.puts("Options:");
util.puts(" -n, --run-count <n> number of runs (default: 10)");
util.puts(" --cache make tested parsers cache results");
util.puts(" -o, --optimize <goal> select optimization for speed or size (default:");
util.puts(" speed)");
console.log("Usage: run [options]");
console.log("");
console.log("Runs PEG.js benchmark suite.");
console.log("");
console.log("Options:");
console.log(" -n, --run-count <n> number of runs (default: 10)");
console.log(" --cache make tested parsers cache results");
console.log(" -o, --optimize <goal> select optimization for speed or size (default:");
console.log(" speed)");
}
function exitSuccess() {
@ -92,7 +91,7 @@ function exitFailure() {
}
function abort(message) {
util.error(message);
console.error(message);
exitFailure();
}

@ -2,7 +2,6 @@
"use strict";
var util = require("util");
var fs = require("fs");
var path = require("path");
var PEG = require("../lib/peg");
@ -10,39 +9,39 @@ var PEG = require("../lib/peg");
/* Helpers */
function printVersion() {
util.puts("PEG.js " + PEG.VERSION);
console.log("PEG.js " + PEG.VERSION);
}
function printHelp() {
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 writes");
util.puts("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");
util.puts(" object will be stored (default:");
util.puts(" \"module.exports\")");
util.puts(" --cache make generated parser cache results");
util.puts(" --allowed-start-rules <rules> comma-separated list of rules the generated");
util.puts(" parser will be allowed to start parsing");
util.puts(" from (default: the first rule in the");
util.puts(" grammar)");
util.puts(" -o, --optimize <goal> select optimization for speed or size");
util.puts(" (default: speed)");
util.puts(" --trace enable tracing in generated parser");
util.puts(" --plugin <plugin> use a specified plugin (can be specified");
util.puts(" multiple times)");
util.puts(" --extra-options <options> additional options (in JSON format) to pass");
util.puts(" to PEG.buildParser");
util.puts(" --extra-options-file <file> file with additional options (in JSON");
util.puts(" format) to pass to PEG.buildParser");
util.puts(" -v, --version print version information and exit");
util.puts(" -h, --help print help and exit");
console.log("Usage: pegjs [options] [--] [<input_file>] [<output_file>]");
console.log("");
console.log("Generates a parser from the PEG grammar specified in the <input_file> and writes");
console.log("it to the <output_file>.");
console.log("");
console.log("If the <output_file> is omitted, its name is generated by changing the");
console.log("<input_file> extension to \".js\". If both <input_file> and <output_file> are");
console.log("omitted, standard input and output are used.");
console.log("");
console.log("Options:");
console.log(" -e, --export-var <variable> name of the variable where the parser");
console.log(" object will be stored (default:");
console.log(" \"module.exports\")");
console.log(" --cache make generated parser cache results");
console.log(" --allowed-start-rules <rules> comma-separated list of rules the generated");
console.log(" parser will be allowed to start parsing");
console.log(" from (default: the first rule in the");
console.log(" grammar)");
console.log(" -o, --optimize <goal> select optimization for speed or size");
console.log(" (default: speed)");
console.log(" --trace enable tracing in generated parser");
console.log(" --plugin <plugin> use a specified plugin (can be specified");
console.log(" multiple times)");
console.log(" --extra-options <options> additional options (in JSON format) to pass");
console.log(" to PEG.buildParser");
console.log(" --extra-options-file <file> file with additional options (in JSON");
console.log(" format) to pass to PEG.buildParser");
console.log(" -v, --version print version information and exit");
console.log(" -h, --help print help and exit");
}
function exitSuccess() {
@ -54,7 +53,7 @@ function exitFailure() {
}
function abort(message) {
util.error(message);
console.error(message);
exitFailure();
}

Loading…
Cancel
Save