From 1b20aa5427234308428aa59b7de9766ae1260f82 Mon Sep 17 00:00:00 2001 From: Futago-za Ryuu Date: Thu, 28 Dec 2017 01:48:01 +0000 Subject: [PATCH] Ensure usage of 'lib/peg.d.ts' This commit ensures that all modules outside 'lib' are importing 'lib/peg.js' so that VS Code automatically gets 'lib/peg.d.ts'. An alias module for 'lib/peg.js' called 'pegjs-dev' was made for test files at 'test/node_modules/pegjs-dev.js' --- bin/options.js | 2 +- test/README.md | 2 ++ test/benchmark/runner.js | 2 +- test/node_modules/pegjs-dev.js | 3 +++ test/spec/api/generated-parser-api.spec.js | 2 +- test/spec/api/pegjs-api.spec.js | 2 +- test/spec/api/plugin-api.spec.js | 2 +- test/spec/behavior/generated-parser-behavior.spec.js | 2 +- test/spec/unit/compiler/passes/generate-bytecode.spec.js | 2 +- test/spec/unit/compiler/passes/helpers.js | 2 +- test/spec/unit/compiler/passes/remove-proxy-rules.spec.js | 2 +- test/spec/unit/compiler/passes/report-duplicate-labels.spec.js | 2 +- test/spec/unit/compiler/passes/report-duplicate-rules.spec.js | 2 +- .../unit/compiler/passes/report-infinite-recursion.spec.js | 2 +- .../unit/compiler/passes/report-infinite-repetition.spec.js | 2 +- test/spec/unit/compiler/passes/report-undefined-rules.spec.js | 2 +- test/spec/unit/parser.spec.js | 2 +- 17 files changed, 20 insertions(+), 15 deletions(-) create mode 100644 test/node_modules/pegjs-dev.js diff --git a/bin/options.js b/bin/options.js index 37f5b84..db44485 100644 --- a/bin/options.js +++ b/bin/options.js @@ -2,7 +2,7 @@ const fs = require( "fs" ); const path = require( "path" ); -const peg = require( "../" ); +const peg = require( "../lib/peg" ); // Options diff --git a/test/README.md b/test/README.md index dfe0540..36f8bbf 100644 --- a/test/README.md +++ b/test/README.md @@ -6,6 +6,8 @@ This directory contains various test suites and scripts to ensure PEG.js works c * [Benchmark Suite](benchmark): It measures speed of the parsers generated by PEG.js on various inputs. Its main goal is to provide data for code generator optimizations. * [Impact Script](impact): Measures impact of a Git commit (or multiple commits) on generated parsers speed and size. +> Note: The package `pegjs-dev`, used by the benchmark and spec modules within this directory, points to '[test/node_modules/pegjs-dev.js](node_modules/pegjs-dev.js)', which is an alias module for '[lib/peg.js](../lib/peg.js)' + ## Download and Install To run the PEG.js test suites you most download the and install the module via the git repository: diff --git a/test/benchmark/runner.js b/test/benchmark/runner.js index 7a6f68c..ddb654d 100644 --- a/test/benchmark/runner.js +++ b/test/benchmark/runner.js @@ -1,6 +1,6 @@ "use strict"; -const peg = require( "../../lib/peg" ); +const peg = require( "pegjs-dev" ); const Runner = { run( benchmarks, runCount, options, callbacks ) { diff --git a/test/node_modules/pegjs-dev.js b/test/node_modules/pegjs-dev.js new file mode 100644 index 0000000..ba2c8a6 --- /dev/null +++ b/test/node_modules/pegjs-dev.js @@ -0,0 +1,3 @@ +"use strict"; + +module.exports = require( "../../lib/peg" ); diff --git a/test/spec/api/generated-parser-api.spec.js b/test/spec/api/generated-parser-api.spec.js index 63b428b..3c68bb8 100644 --- a/test/spec/api/generated-parser-api.spec.js +++ b/test/spec/api/generated-parser-api.spec.js @@ -1,7 +1,7 @@ "use strict"; const chai = require( "chai" ); -const peg = require( "../../../lib/peg" ); +const peg = require( "pegjs-dev" ); const sinon = require( "sinon" ); const expect = chai.expect; diff --git a/test/spec/api/pegjs-api.spec.js b/test/spec/api/pegjs-api.spec.js index 4e8e422..423b673 100644 --- a/test/spec/api/pegjs-api.spec.js +++ b/test/spec/api/pegjs-api.spec.js @@ -1,7 +1,7 @@ "use strict"; const chai = require( "chai" ); -const peg = require( "../../../lib/peg" ); +const peg = require( "pegjs-dev" ); const sinon = require( "sinon" ); const expect = chai.expect; diff --git a/test/spec/api/plugin-api.spec.js b/test/spec/api/plugin-api.spec.js index 31eae10..8b60e09 100644 --- a/test/spec/api/plugin-api.spec.js +++ b/test/spec/api/plugin-api.spec.js @@ -1,7 +1,7 @@ "use strict"; const chai = require( "chai" ); -const peg = require( "../../../lib/peg" ); +const peg = require( "pegjs-dev" ); const expect = chai.expect; diff --git a/test/spec/behavior/generated-parser-behavior.spec.js b/test/spec/behavior/generated-parser-behavior.spec.js index 472ee1f..60a7c98 100644 --- a/test/spec/behavior/generated-parser-behavior.spec.js +++ b/test/spec/behavior/generated-parser-behavior.spec.js @@ -1,7 +1,7 @@ "use strict"; const chai = require( "chai" ); -const peg = require( "../../../lib/peg" ); +const peg = require( "pegjs-dev" ); const sinon = require( "sinon" ); const expect = chai.expect; diff --git a/test/spec/unit/compiler/passes/generate-bytecode.spec.js b/test/spec/unit/compiler/passes/generate-bytecode.spec.js index 71f33a0..0fd50ac 100644 --- a/test/spec/unit/compiler/passes/generate-bytecode.spec.js +++ b/test/spec/unit/compiler/passes/generate-bytecode.spec.js @@ -2,7 +2,7 @@ const chai = require( "chai" ); const helpers = require( "./helpers" ); -const pass = require( "../../../../../lib/compiler/passes/generate-bytecode" ); +const pass = require( "pegjs-dev" ).compiler.passes.generate.generateBytecode; chai.use( helpers ); diff --git a/test/spec/unit/compiler/passes/helpers.js b/test/spec/unit/compiler/passes/helpers.js index d897108..c5c8e9e 100644 --- a/test/spec/unit/compiler/passes/helpers.js +++ b/test/spec/unit/compiler/passes/helpers.js @@ -1,6 +1,6 @@ "use strict"; -const parser = require( "../../../../../lib/parser" ); +const parser = require( "pegjs-dev" ).parser; module.exports = function ( chai, utils ) { diff --git a/test/spec/unit/compiler/passes/remove-proxy-rules.spec.js b/test/spec/unit/compiler/passes/remove-proxy-rules.spec.js index 3579a7f..817111e 100644 --- a/test/spec/unit/compiler/passes/remove-proxy-rules.spec.js +++ b/test/spec/unit/compiler/passes/remove-proxy-rules.spec.js @@ -2,7 +2,7 @@ const chai = require( "chai" ); const helpers = require( "./helpers" ); -const pass = require( "../../../../../lib/compiler/passes/remove-proxy-rules" ); +const pass = require( "pegjs-dev" ).compiler.passes.transform.removeProxyRules; chai.use( helpers ); diff --git a/test/spec/unit/compiler/passes/report-duplicate-labels.spec.js b/test/spec/unit/compiler/passes/report-duplicate-labels.spec.js index a96d9bd..8ca045a 100644 --- a/test/spec/unit/compiler/passes/report-duplicate-labels.spec.js +++ b/test/spec/unit/compiler/passes/report-duplicate-labels.spec.js @@ -2,7 +2,7 @@ const chai = require( "chai" ); const helpers = require( "./helpers" ); -const pass = require( "../../../../../lib/compiler/passes/report-duplicate-labels" ); +const pass = require( "pegjs-dev" ).compiler.passes.check.reportDuplicateLabels; chai.use( helpers ); diff --git a/test/spec/unit/compiler/passes/report-duplicate-rules.spec.js b/test/spec/unit/compiler/passes/report-duplicate-rules.spec.js index d73a7cf..97a6f45 100644 --- a/test/spec/unit/compiler/passes/report-duplicate-rules.spec.js +++ b/test/spec/unit/compiler/passes/report-duplicate-rules.spec.js @@ -2,7 +2,7 @@ const chai = require( "chai" ); const helpers = require( "./helpers" ); -const pass = require( "../../../../../lib/compiler/passes/report-duplicate-rules" ); +const pass = require( "pegjs-dev" ).compiler.passes.check.reportDuplicateRules; chai.use( helpers ); diff --git a/test/spec/unit/compiler/passes/report-infinite-recursion.spec.js b/test/spec/unit/compiler/passes/report-infinite-recursion.spec.js index f11b939..c470e92 100644 --- a/test/spec/unit/compiler/passes/report-infinite-recursion.spec.js +++ b/test/spec/unit/compiler/passes/report-infinite-recursion.spec.js @@ -2,7 +2,7 @@ const chai = require( "chai" ); const helpers = require( "./helpers" ); -const pass = require( "../../../../../lib/compiler/passes/report-infinite-recursion" ); +const pass = require( "pegjs-dev" ).compiler.passes.check.reportInfiniteRecursion; chai.use( helpers ); diff --git a/test/spec/unit/compiler/passes/report-infinite-repetition.spec.js b/test/spec/unit/compiler/passes/report-infinite-repetition.spec.js index c7119f8..a1f2ff8 100644 --- a/test/spec/unit/compiler/passes/report-infinite-repetition.spec.js +++ b/test/spec/unit/compiler/passes/report-infinite-repetition.spec.js @@ -2,7 +2,7 @@ const chai = require( "chai" ); const helpers = require( "./helpers" ); -const pass = require( "../../../../../lib/compiler/passes/report-infinite-repetition" ); +const pass = require( "pegjs-dev" ).compiler.passes.check.reportInfiniteRepetition; chai.use( helpers ); diff --git a/test/spec/unit/compiler/passes/report-undefined-rules.spec.js b/test/spec/unit/compiler/passes/report-undefined-rules.spec.js index 3a0b18e..6a64a56 100644 --- a/test/spec/unit/compiler/passes/report-undefined-rules.spec.js +++ b/test/spec/unit/compiler/passes/report-undefined-rules.spec.js @@ -2,7 +2,7 @@ const chai = require( "chai" ); const helpers = require( "./helpers" ); -const pass = require( "../../../../../lib/compiler/passes/report-undefined-rules" ); +const pass = require( "pegjs-dev" ).compiler.passes.check.reportUndefinedRules; chai.use( helpers ); diff --git a/test/spec/unit/parser.spec.js b/test/spec/unit/parser.spec.js index 6a5c72f..5f334f0 100644 --- a/test/spec/unit/parser.spec.js +++ b/test/spec/unit/parser.spec.js @@ -1,7 +1,7 @@ "use strict"; const chai = require( "chai" ); -const parser = require( "../../../lib/parser" ); +const parser = require( "pegjs-dev" ).parser; const expect = chai.expect;