Skip to content

Commit 74d6435

Browse files
liuxy0551LuckyFBB
authored andcommitted
fix: #351 antlr4 command optimize
1 parent 74be81c commit 74d6435

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

scripts/antlr4.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ const { cleanComment } = require('./cleanComment');
99
const grammarsPath = path.resolve(__dirname, '../src/grammar');
1010
const outputPath = path.resolve(__dirname, '../src/lib');
1111

12-
const languageEntries = fs.readdirSync(grammarsPath);
12+
const languageEntries = fs.readdirSync(grammarsPath).filter((language) => {
13+
return fs.statSync(path.join(grammarsPath, language)).isDirectory();
14+
});
1315

1416
const baseCmd = 'antlr4ng -Dlanguage=TypeScript -visitor -listener -Xexact-output-dir -o';
1517

@@ -65,7 +67,7 @@ function main() {
6567
languageEntries.forEach((language) => {
6668
compile(language);
6769
});
68-
} else if (argv.lang) {
70+
} else if (argv.lang && typeof argv.lang === 'string') {
6971
// compile single: yarn antlr4 --lang=mysql
7072
const supportedLanguage = languageEntries.find((language) =>
7173
language.startsWith(argv.lang)

0 commit comments

Comments
 (0)