Skip to content

Commit

Permalink
use the entire basename in config file paths
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed Nov 19, 2022
1 parent 0214607 commit b6541fe
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/kbn-es-query/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PKG_REQUIRE_NAME = "@kbn/es-query"
SOURCE_FILES = glob(
[
"**/*.ts",
"**/grammar.config.json",
"**/grammar.peggy.config.json",
"**/grammar.peggy",
],
exclude = [
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-interpreter/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ SOURCE_FILES = glob(
[
"**/*.ts",
"**/*.js",
"**/grammar.config.json",
"**/grammar.peggy.config.json",
"**/grammar.peggy",
],
exclude = [
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-peggy/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ tags: ['kibana', 'dev', 'contributor', 'operations', 'peggy']

This package wraps the peggy package, exposing a synchronous and async version of the generator which includes two modifications:

1. When a `path` is provided a `${basename}.config.json` file will be loaded if it exists and it expected to include peggy config options as defined in [the peggy docs](https://peggyjs.org/documentation.html#generating-a-parser-javascript-api). This config will be used when compiling this file
1. When a `path` is provided a `${basename}.config.json` file will be loaded if it exists and is expected to include peggy config options as defined in [the peggy docs](https://peggyjs.org/documentation.html#generating-a-parser-javascript-api). This config will be used when compiling this file

## Plugins
These types will automatically be included for plugins.
Expand Down
10 changes: 1 addition & 9 deletions packages/kbn-peggy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,7 @@ export interface Result {
}

export function findConfigFile(grammarPath: string): Config | undefined {
const extname = Path.extname(grammarPath);
if (extname !== '.peggy') {
throw new Error(`unexpected extension [${extname}], expected ".peggy"`);
}

const path = Path.resolve(
Path.dirname(grammarPath),
`${Path.basename(grammarPath, extname)}.config.json`
);
const path = Path.resolve(Path.dirname(grammarPath), `${Path.basename(grammarPath)}.config.json`);

let source;
let parsed;
Expand Down

0 comments on commit b6541fe

Please sign in to comment.