From 2dc39bb77930dbae83d5815551d395a54b64a177 Mon Sep 17 00:00:00 2001 From: David Majda Date: Mon, 14 Jan 2013 20:33:35 +0100 Subject: [PATCH] bin/pegjs: Output just the parser source if --export-var is empty This will make embedding generated parsers into other files easier. Based on a patch by Glen Huang: https://github.com/dmajda/pegjs/pull/143 --- bin/pegjs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/pegjs b/bin/pegjs index a20aec8..20bd43c 100755 --- a/bin/pegjs +++ b/bin/pegjs @@ -197,7 +197,9 @@ readStream(inputStream, function(input) { } } - outputStream.write(exportVar + " = " + source + ";\n"); + outputStream.write( + exportVar !== "" ? exportVar + " = " + source + ";\n" : source + "\n" + ); if (outputStream !== process.stdout) { outputStream.end(); }