Skip to content

Commit

Permalink
Better antlr4 workaround (#1325)
Browse files Browse the repository at this point in the history
* antlr4 workaround contained entirely within js

* Resolve path correctly on non-Windows systems
  • Loading branch information
mint-thompson authored Aug 21, 2023
1 parent 503e1b9 commit 754a4ed
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
7 changes: 6 additions & 1 deletion dev/fixAntlr4.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@

const fs = require('fs-extra');
const path = require('path');
const execSync = require('child_process').execSync;
// the directory containing .babelrc is one step up
const antlr4Path = path.join(path.dirname(require.resolve('antlr4')), '..');

const antlr4BabelPath = path.join(__dirname, '..', 'node_modules', 'antlr4', '.babelrc');
const antlr4BabelPath = path.join(antlr4Path, '.babelrc');
const babelContents = {
presets: ['@babel/preset-env'],
targets: 'defaults'
};
fs.writeJSONSync(antlr4BabelPath, babelContents);

execSync('npm install', { cwd: antlr4Path });
12 changes: 3 additions & 9 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"postinstall": "npm run fixAntlr4",
"prepublishOnly": "npm run check && npm run fixGrammarTypes",
"fixGrammarTypes": "ts-node dev/fixGrammarTypes.ts",
"fixAntlr4": "node dev/fixAntlr4.js && cd node_modules && cd antlr4 && npm install && npm run build"
"fixAntlr4": "node dev/fixAntlr4.js"
},
"contributors": [
"Julia Afeltra <[email protected]>",
Expand Down

0 comments on commit 754a4ed

Please sign in to comment.