From 8f16d575d52649abb364a3e441f14bd7fa6c0362 Mon Sep 17 00:00:00 2001 From: houhaoyu Date: Fri, 15 Oct 2021 14:53:42 +0800 Subject: [PATCH] houhaoyu@huawei.com Signed-off-by: houhaoyu Change-Id: I5a093723aff87f4f21e1c7c6b478142967c6058a --- compiler/build_peg.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/compiler/build_peg.js b/compiler/build_peg.js index 3174132..b1cb34d 100644 --- a/compiler/build_peg.js +++ b/compiler/build_peg.js @@ -20,10 +20,11 @@ const fs = require('fs'); const path = require('path'); function generatePeg(inputFile) { - const readDirPath = path.resolve(__dirname, './peg_parser/src/'); + const readDirPath = path.resolve(__dirname, './peg_parser/src'); const readDirSubFiles = fs.readdirSync(readDirPath); const catalogPath = path.resolve(inputFile, '..'); const catalogSubFiles = fs.readdirSync(catalogPath) + const pegjs = path.resolve(__dirname, './node_modules/pegjs/bin/pegjs'); if (catalogSubFiles.includes('dist')) { exec('rm -rf ' + catalogPath + '/dist/*.js'); @@ -31,11 +32,13 @@ function generatePeg(inputFile) { exec('mkdir ' + catalogPath + '/dist'); } - (async function pegTransJs () { + ;(async function pegTransJs () { if (readDirSubFiles.length) { for (let item of readDirSubFiles) { let name = path.basename(item, '.peg'); - await exec('pegjs -o ' + catalogPath + '/dist/' + name + '.js ' + readDirPath + '/' + item); + if (name){ + await exec(pegjs + ' -o ' + catalogPath + '/dist/' + name + '.js ' + readDirPath + '/' + item); + } } } })()