From 74d643599eb5603279a180262c49eccb04779a30 Mon Sep 17 00:00:00 2001 From: liuxy0551 Date: Wed, 8 Jan 2025 11:07:33 +0800 Subject: [PATCH] fix: #351 antlr4 command optimize --- scripts/antlr4.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/antlr4.js b/scripts/antlr4.js index 2ca03926..0ff06881 100644 --- a/scripts/antlr4.js +++ b/scripts/antlr4.js @@ -9,7 +9,9 @@ const { cleanComment } = require('./cleanComment'); const grammarsPath = path.resolve(__dirname, '../src/grammar'); const outputPath = path.resolve(__dirname, '../src/lib'); -const languageEntries = fs.readdirSync(grammarsPath); +const languageEntries = fs.readdirSync(grammarsPath).filter((language) => { + return fs.statSync(path.join(grammarsPath, language)).isDirectory(); +}); const baseCmd = 'antlr4ng -Dlanguage=TypeScript -visitor -listener -Xexact-output-dir -o'; @@ -65,7 +67,7 @@ function main() { languageEntries.forEach((language) => { compile(language); }); - } else if (argv.lang) { + } else if (argv.lang && typeof argv.lang === 'string') { // compile single: yarn antlr4 --lang=mysql const supportedLanguage = languageEntries.find((language) => language.startsWith(argv.lang)