From dcf904c392c16cd02aea034ce936336a448b8fb2 Mon Sep 17 00:00:00 2001 From: David Majda Date: Sun, 13 Feb 2011 12:43:12 +0100 Subject: [PATCH] bin/pegjs: Default parser variable name is "module.exports" The previous default name was "exports.parser". This meant that to use the generated parser in Node.js, you had to use code like this: var parser = require("./my-cool-parser").parser; parser.parse(...); Now you can shorten it a bit: var parser = require("./my-cool-parser"); parser.parse(...); The shorter version makes sense since no other objects except the parser are exported from the module. --- bin/pegjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/pegjs b/bin/pegjs index 7693eca..c24246e 100755 --- a/bin/pegjs +++ b/bin/pegjs @@ -22,7 +22,7 @@ function printHelp() { sys.puts(""); sys.puts("Options:"); sys.puts(" -e, --export-var name of the variable where the parser object"); - sys.puts(" will be stored (default: \"exports.parser\")"); + 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"); } @@ -63,7 +63,7 @@ function readStream(inputStream, callback) { /* Main */ /* This makes the generated parser a CommonJS module by default. */ -var exportVar = "exports.parser"; +var exportVar = "module.exports"; while (args.length > 0 && isOption(args[0])) { switch (args[0]) {