Skip to content

Commit

Permalink
Merge pull request peggyjs#537 from hildjj/update-deps
Browse files Browse the repository at this point in the history
Update dependencies.  Fix weird pnpm reinstall issue.
  • Loading branch information
hildjj authored Jul 16, 2024
2 parents e2c7f84 + 6a53389 commit 4036dab
Show file tree
Hide file tree
Showing 27 changed files with 1,552 additions and 2,373 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ tools
tsconfig*.json
web-test/
yarn.lock
pnpm-workspace.yaml
34 changes: 17 additions & 17 deletions bin/peggy-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,11 @@ function readStream(inputStream) {
}

function readFile(name) {
let f = null;
try {
f = fs.readFileSync(name, "utf8");
return fs.readFileSync(name, "utf8");
} catch (e) {
throw new InvalidArgumentError(`Can't read from file "${name}".`, e);
}
return f;
}

async function ensureDirectoryExists(filename) {
Expand Down Expand Up @@ -161,13 +159,12 @@ class PeggyCLI extends Command {
"-D, --dependencies <json>",
"Dependencies, in JSON object format with variable:module pairs. (Can be specified multiple times).",
(val, prev = {}) => {
let v = null;
try {
v = JSON.parse(val);
const v = JSON.parse(val);
return Object.assign(prev, v);
} catch (e) {
throw new InvalidArgumentError(`Error parsing JSON: ${e.message}`);
}
return Object.assign(prev, v);
}
)
.option(
Expand Down Expand Up @@ -477,15 +474,12 @@ class PeggyCLI extends Command {
* @returns {peggy.BuildOptionsBase}
*/
addExtraOptionsJSON(json, source) {
let extraOptions = undefined;

try {
extraOptions = JSON.parse(json);
const extraOptions = JSON.parse(json);
return this.addExtraOptions(extraOptions, source);
} catch (e) {
throw new InvalidArgumentError(`Error parsing JSON: ${e.message}`);
}

return this.addExtraOptions(extraOptions, source);
}

/**
Expand Down Expand Up @@ -667,7 +661,8 @@ class PeggyCLI extends Command {
try {
for (const source of this.inputFiles) {
const input = { source, text: null };
this.verbose("CLI", errorText = `reading input "${source}"`);
errorText = `reading input "${source}"`;
this.verbose("CLI", errorText);
if (source === "-") {
input.source = "stdin";
this.std.in.resume();
Expand All @@ -687,25 +682,30 @@ class PeggyCLI extends Command {
// This is wrong. It's a hack in place until source generation is fixed.
this.argv.grammarSource = sources[0].source;

this.verbose("CLI", errorText = "parsing grammar");
errorText = "parsing grammar";
this.verbose("CLI", errorText);
const source = peggy.generate(sources, this.argv); // All of the real work.

this.verbose("CLI", errorText = "opening output stream");
errorText = "opening output stream";
this.verbose("CLI", errorText);
const outputStream = await this.openOutputStream();

// If option `--ast` is specified, `generate()` returns an AST object
if (this.progOptions.ast) {
this.verbose("CLI", errorText = "writing AST");
await this.writeOutput(outputStream, JSON.stringify(source, null, 2));
} else {
this.verbose("CLI", errorText = "writing sourceMap");
errorText = "writing sourceMap";
this.verbose("CLI", errorText);
const mappedSource = await this.writeSourceMap(source);

this.verbose("CLI", errorText = "writing parser");
errorText = "writing parser";
this.verbose("CLI", errorText);
await this.writeOutput(outputStream, mappedSource);

exitCode = 2;
this.verbose("CLI", errorText = "running test");
errorText = "running test";
this.verbose("CLI", errorText);
await this.test(mappedSource);
}
} catch (error) {
Expand Down
1 change: 0 additions & 1 deletion bin/watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class Watcher extends EventEmitter {
this.watchers = [];

for (const dir of dirs) {
// eslint-disable-next-line func-style -- Needs "this"
const changed = (_typ, fn) => {
if (typeof this.timeout === "symbol") {
return;
Expand Down
2 changes: 1 addition & 1 deletion docs/js/benchmark-bundle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/js/test-bundle.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 4036dab

Please sign in to comment.