From 55379f3cf5a88ae7682d2a9d1a08a509e73c1263 Mon Sep 17 00:00:00 2001 From: hayden Date: Thu, 16 Nov 2023 20:35:44 +0800 Subject: [PATCH] build: fix antlr4 script --- scripts/antlr4.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/antlr4.js b/scripts/antlr4.js index 4bc93f9..11c9c76 100644 --- a/scripts/antlr4.js +++ b/scripts/antlr4.js @@ -15,8 +15,10 @@ const baseCmd = 'antlr4ts -visitor -listener -Xexact-output-dir -o'; function compile(language) { const cmd = `${baseCmd} ${outputPath}/${language} ${grammarsPath}/${language}/*.g4`; - console.info(chalk.green(`\nRemoving:`, chalk.gray(`${outputPath}/${language}/*`))); - fs.rmSync(`${outputPath}/${language}`, { recursive: true }); + if (fs.existsSync(`${outputPath}/${language}`)) { + console.info(chalk.green(`\nRemoving:`, chalk.gray(`${outputPath}/${language}/*`))); + fs.rmSync(`${outputPath}/${language}`, { recursive: true }); + } console.info(chalk.green('Executing:'), chalk.gray(cmd)); exec(cmd, (err) => {