Ensure VERSION is consistent

The PEG.js version is exported and also written into the generated parser. In both these instances the version is a separate string, which means every time the version is bumped, it has to be changed in 3 places. This commit makes it slightly less of a maintenance burden.
master
Futago-za Ryuu 6 years ago
parent ecb81504cb
commit 95abd42c95

@ -3,6 +3,7 @@
"use strict";
const util = require( "../../util" );
const VERSION = require( "../../version" );
// Generates parser JavaScript code.
function generateJS( ast, session, options ) {
@ -1593,7 +1594,7 @@ function generateJS( ast, session, options ) {
function generateHeaderComment() {
let comment = "// Generated by PEG.js v0.11.0-dev, https://pegjs.org/";
let comment = `// Generated by PEG.js ${ VERSION }, https://pegjs.org/`;
const header = options.header;
if ( typeof header === "string" ) {

@ -1,4 +1,4 @@
// Generated by PEG.js v0.11.0-dev, https://pegjs.org/
// Generated by PEG.js 0.11.0-dev, https://pegjs.org/
/* eslint-disable */

@ -5,10 +5,11 @@ const ast = require( "./ast" );
const compiler = require( "./compiler" );
const parser = require( "./parser" );
const util = require( "./util" );
const VERSION = require( "./version" );
const peg = {
// PEG.js version (uses semantic versioning).
VERSION: "0.11.0-dev",
VERSION: VERSION,
GrammarError: GrammarError,
ast: ast,

@ -0,0 +1,8 @@
"use strict";
/**
* PEG.js version (uses semantic versioning).
*/
const VERSION = "0.11.0-dev";
module.exports = VERSION;

@ -6,6 +6,12 @@ declare module "pegjs" {
}
declare module "pegjs/lib/version" {
export default peg.VERSION;
}
declare module "pegjs/lib/grammar-error" {
export default peg.GrammarError;

Loading…
Cancel
Save