Skip to content

Commit db30b58

Browse files
authored
Merge pull request peggyjs#8 from hildjj/maxFailPos
maxFailPos
2 parents 1103908 + 3962202 commit db30b58

File tree

9 files changed

+970
-409
lines changed

9 files changed

+970
-409
lines changed

.github/workflows/node.js.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ on:
66
branches: [main]
77
pull_request:
88
branches: [main]
9+
workflow_call:
10+
secrets:
11+
CODECOV_TOKEN:
12+
required: true
913

1014
jobs:
1115
build:
1216

1317
strategy:
1418
matrix:
15-
node-version: [18.x, 20.x, 21.x, 22.x]
19+
node-version: [18.x, 20.x, 21.x, 22.x, 23.x]
1620
platform: [ubuntu-latest]
1721

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

.github/workflows/publish.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Publish Package to npmjs
2+
on:
3+
release:
4+
types: [published]
5+
workflow_call:
6+
secrets:
7+
NPM_TOKEN:
8+
required: true
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
id-token: write
16+
steps:
17+
- uses: actions/checkout@v4
18+
- run: corepack enable
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: '22.x'
22+
registry-url: 'https://registry.npmjs.org'
23+
cache: pnpm
24+
- run: pnpm i -r
25+
- run: npm run build
26+
- run: npm run test
27+
- run: npm pkg delete devDependencies scripts packageManager
28+
- run: npm publish --access public --provenance
29+
env:
30+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
coverage/
2-
node_modules/
2+
node_modules/
3+
.vscode/

eslint.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import js from "@peggyjs/eslint-config/flat/module.js";
2-
import modern from "@peggyjs/eslint-config/flat/modern.js";
1+
import js from "@peggyjs/eslint-config/module.js";
2+
import modern from "@peggyjs/eslint-config/modern.js";
33

44
export default [
55
{
@@ -9,6 +9,6 @@ export default [
99
"**/*.ts",
1010
],
1111
},
12-
js,
13-
modern,
12+
...js,
13+
...modern,
1414
];

lib/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ export type PeggyTestOptions<T> = {
7171
/**
7272
* See https://github.com/peggyjs/peggy/issues/512
7373
*/
74-
export type Parser = import('peggy').Parser & {
74+
export type Parser = import("peggy").Parser & {
7575
StartRules: string[];
7676
};
77-
export type Location = import('peggy').Location;
77+
export type Location = import("peggy").Location;
7878
export type TestPeggyOptions = {
7979
/**
8080
* Do not delete the generated file.

lib/index.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ let counter = 0;
6565
function checkParserStarts(grammar, starts, modified, counts) {
6666
for (const start of starts) {
6767
const startRule = start.startRule || undefined; // NOT `??`
68-
const peg$maxFailPos = start.peg$maxFailPos ?? 0;
68+
const peg$maxFailPos = start.peg$maxFailPos ?? undefined;
6969
const options = start.options ?? {};
7070
const invalid = start.invalid ?? INVALID;
7171
if (!modified && options.peg$startRuleFunction) {
@@ -93,12 +93,19 @@ function checkParserStarts(grammar, starts, modified, counts) {
9393
peg$FAILED: {},
9494
peg$maxFailPos,
9595
};
96+
if (peg$maxFailPos === undefined) {
97+
delete expectedLib.peg$maxFailPos;
98+
}
9699
let lib = grammar.parse(start.validInput, {
97100
peg$library: true,
98101
startRule,
99102
...options,
100103
});
101104
delete lib.peg$maxFailExpected;
105+
if (peg$maxFailPos === undefined) {
106+
delete lib.peg$maxFailPos;
107+
}
108+
102109
if (typeof expected === "function") {
103110
// @ts-ignore
104111
lib.peg$result = expected(lib.peg$result);
@@ -112,6 +119,9 @@ function checkParserStarts(grammar, starts, modified, counts) {
112119
...options,
113120
});
114121
delete lib.peg$maxFailExpected;
122+
if (peg$maxFailPos === undefined) {
123+
delete lib.peg$maxFailPos;
124+
}
115125
if (typeof expected === "function") {
116126
// @ts-ignore
117127
lib.peg$result = expected(lib.peg$result);

package.json

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@peggyjs/coverage",
3-
"version": "1.1.1",
3+
"version": "1.2.0",
44
"decription": "Generate better code coverage for Peggy grammars",
55
"main": "lib/index.js",
66
"type": "module",
@@ -28,17 +28,23 @@
2828
"test": "c8 node --test test/*.test.js"
2929
},
3030
"dependencies": {
31-
"peggy": "4.0.2",
31+
"peggy": "4.1.1",
3232
"source-map-generator": "0.8.0"
3333
},
3434
"devDependencies": {
35-
"@peggyjs/eslint-config": "3.2.4",
36-
"@types/node": "20.12.10",
37-
"c8": "9.1.0",
38-
"eslint": "8.57.0",
39-
"typescript": "5.4.5"
35+
"@peggyjs/eslint-config": "5.0.1",
36+
"@types/node": "22.9.0",
37+
"c8": "10.1.2",
38+
"eslint": "9.14.0",
39+
"typescript": "5.6.3"
40+
},
41+
"packageManager": "[email protected]",
42+
"pnpm": {
43+
"overrides": {
44+
"braces": "^3.0.3",
45+
"micromatch": "^4.0.8"
46+
}
4047
},
41-
"packageManager": "[email protected]",
4248
"engines": {
4349
"node": ">=18"
4450
}

0 commit comments

Comments
 (0)