Browse Source

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 3 years ago
parent
commit
95abd42c95
  1. 3
      packages/pegjs/lib/compiler/passes/generate-js.js
  2. 2
      packages/pegjs/lib/parser.js
  3. 3
      packages/pegjs/lib/peg.js
  4. 8
      packages/pegjs/lib/version.js
  5. 6
      packages/pegjs/typings/modules.d.ts

3
packages/pegjs/lib/compiler/passes/generate-js.js

@ -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" ) {

2
packages/pegjs/lib/parser.js

@ -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 */

3
packages/pegjs/lib/peg.js

@ -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,

8
packages/pegjs/lib/version.js

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

6
packages/pegjs/typings/modules.d.ts

@ -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