Skip to content

Commit 92dc468

Browse files
authored
Merge pull request #16 from hildjj/update-dependencies
Update dependencies, including Peggy. BREAKING: next release will require node 20
2 parents d19040d + c7766b2 commit 92dc468

File tree

11 files changed

+1176
-501
lines changed

11 files changed

+1176
-501
lines changed

.github/workflows/gh-pages.yml

-34
This file was deleted.

.github/workflows/node.js.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
strategy:
1818
matrix:
19-
node-version: [18.x, 20.x, 21.x, 22.x, 23.x]
19+
node-version: [20, 22, 23]
2020
platform: [ubuntu-latest]
2121

2222
runs-on: ${{ matrix.platform }}

.github/workflows/publish.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- uses: pnpm/action-setup@v4
1919
- uses: actions/setup-node@v4
2020
with:
21-
node-version: '22.x'
21+
node-version: 22
2222
registry-url: 'https://registry.npmjs.org'
2323
cache: pnpm
2424
- run: pnpm i -r

.npmignore

-11
This file was deleted.

lib/index.d.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@
1818
* @param {TestPeggyOptions} [opts] Options for processing.
1919
* @returns {Promise<TestCounts>}
2020
*/
21-
export function testPeggy<T>(grammarUrl: URL | string, starts: PeggyTestOptions<T>[], opts?: TestPeggyOptions | undefined): Promise<TestCounts>;
21+
export function testPeggy<T>(grammarUrl: URL | string, starts: PeggyTestOptions<T>[], opts?: TestPeggyOptions): Promise<TestCounts>;
2222
export type TestCounts = {
2323
valid: number;
2424
invalid: number;
25+
total: number;
2526
grammarPath: string;
2627
modifiedPath: string;
2728
};

lib/index.js

+19-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
ok,
66
throws,
77
} from "node:assert/strict";
8-
import { SourceNode } from "source-map-generator";
8+
import { SourceNode } from "source-map";
99
import { fileURLToPath } from "node:url";
1010
import fs from "node:fs/promises";
1111
import path from "node:path";
@@ -70,7 +70,7 @@ let counter = 0;
7070
* @param {string} text
7171
*/
7272
function format(e, source, text) {
73-
const er = /** @type {import('peggy').parser.SyntaxError} */(e);
73+
const er = /** @type {import('peggy').parser.PeggySyntaxError} */(e);
7474
if (typeof er?.format === "function") {
7575
er.message = er.format([{ source, text }]);
7676
}
@@ -149,6 +149,10 @@ function checkParserStarts(grammar, starts, modified, counts) {
149149
throw new Error(`Failed in library context: ${source}`);
150150
}
151151

152+
// @ts-expect-error This is for testing.
153+
delete lib.peg$success;
154+
// @ts-expect-error This is for testing.
155+
delete lib.peg$throw;
152156
// @ts-expect-error This is for testing.
153157
delete lib.peg$maxFailExpected;
154158
if (peg$maxFailPos === undefined) {
@@ -171,6 +175,10 @@ function checkParserStarts(grammar, starts, modified, counts) {
171175
...options,
172176
});
173177

178+
// @ts-expect-error This is for testing.
179+
delete lib.peg$success;
180+
// @ts-expect-error This is for testing.
181+
delete lib.peg$throw;
174182
// @ts-expect-error This is for testing.
175183
delete lib.peg$maxFailExpected;
176184
if (peg$maxFailPos === undefined) {
@@ -415,11 +423,19 @@ export async function testPeggy(grammarUrl, starts, opts) {
415423
peg$endExpectation(),
416424
peg$otherExpectation('one'),
417425
], "", loc);
418-
peg$padEnd("foo", 2);
419426
const oldMax = peg$maxFailPos;
420427
peg$maxFailPos = Infinity;
421428
peg$fail();
422429
peg$maxFailPos = oldMax;
430+
431+
const {unicode} = RegExp.prototype;
432+
delete RegExp.prototype.unicode;
433+
const u_err = peg$buildStructuredError([
434+
peg$otherExpectation('one'),
435+
peg$anyExpectation(),
436+
], "\u{1F4A9}", loc);
437+
RegExp.prototype.unicode = unicode
438+
peg$getUnicode(Infinity);
423439
})();
424440
//#endregion
425441

package.json

+12-9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"decription": "Generate better code coverage for Peggy grammars",
55
"main": "lib/index.js",
66
"type": "module",
7+
"files": [
8+
"lib/"
9+
],
710
"keywords": [
811
"peggy,",
912
"pegjs,",
@@ -23,24 +26,24 @@
2326
"url": "https://github.com/peggyjs/coverage/issues"
2427
},
2528
"scripts": {
26-
"build": "peggy --format es test/minimal.peggy && tsc",
29+
"build": "peggy -c peggy.config.js && tsc",
2730
"docs": "typedoc",
2831
"lint": "eslint .",
2932
"test": "c8 node --test test/*.test.js"
3033
},
3134
"dependencies": {
32-
"peggy": "4.2.0",
33-
"source-map-generator": "0.8.0"
35+
"peggy": "5.0.0",
36+
"source-map": "0.7.4"
3437
},
3538
"devDependencies": {
36-
"@peggyjs/eslint-config": "5.0.3",
37-
"@types/node": "22.13.4",
39+
"@peggyjs/eslint-config": "6.0.0",
40+
"@types/node": "22.15.3",
3841
"c8": "10.1.3",
39-
"eslint": "9.20.1",
40-
"typedoc": "0.27.7",
41-
"typescript": "5.7.3"
42+
"eslint": "9.26.0",
43+
"typedoc": "0.28.3",
44+
"typescript": "5.8.3"
4245
},
43-
"packageManager": "pnpm@10.4.0",
46+
"packageManager": "pnpm@10.10.0",
4447
"engines": {
4548
"node": ">=18"
4649
}

peggy.config.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default {
2+
input: "test/minimal.peggy",
3+
format: "es",
4+
allowedStartRules: [
5+
"foo",
6+
"not_lib",
7+
],
8+
};

0 commit comments

Comments
 (0)