From 3b83a421461e48ff2d3562caa367a92bb55b2628 Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Mon, 7 Jul 2025 23:00:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BC=95=E7=94=A8=E5=AD=97?= =?UTF-8?q?=E8=8A=82=E7=A0=81har=E6=84=8F=E5=9B=BE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=B6=88=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangzezhong --- compiler/src/userIntents_parser/parseUserIntents.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/src/userIntents_parser/parseUserIntents.ts b/compiler/src/userIntents_parser/parseUserIntents.ts index 3cfec8eea..09e164451 100644 --- a/compiler/src/userIntents_parser/parseUserIntents.ts +++ b/compiler/src/userIntents_parser/parseUserIntents.ts @@ -1561,7 +1561,7 @@ class ParseIntent { const cacheSourceMapPath: string = path.join(projectConfig.aceProfilePath, 'insight_intent.json'); // The user's intents configuration file try { - if (this.intentData.length > 0) { + if (Object.keys(mergedData).length > 0) { fs.writeFileSync(cacheSourceMapPath, JSON.stringify(mergedData, null, 2), 'utf-8'); fs.writeFileSync(cachePath, JSON.stringify({ 'extractInsightIntents': this.intentData }, null, 2), 'utf-8'); } else if (fs.existsSync(cacheSourceMapPath)) { @@ -1573,7 +1573,7 @@ class ParseIntent { const rawData: string = fs.readFileSync(fullPath, 'utf8'); const jsonData: object = JSON.parse(rawData); if (jsonData?.module) { - jsonData.module.hasInsightIntent = this.intentData.length > 0 ? true : undefined; + jsonData.module.hasInsightIntent = Object.keys(mergedData).length > 0 ? true : undefined; } const updatedJson: string = JSON.stringify(jsonData, null, 2); fs.writeFileSync(fullPath, updatedJson, 'utf8'); @@ -1629,13 +1629,13 @@ class ParseIntent { 'extractInsightIntents': this.intentData }); writeJsonData = jsonData; - } else { + } else if (this.intentData.length > 0) { Object.assign(writeJsonData, { 'extractInsightIntents': this.intentData }); } const mergedData: object = this.mergeHarData(writeJsonData, harIntentDataObj); - this.validateIntentIntentName(writeJsonData); + this.validateIntentIntentName(mergedData); return mergedData; } @@ -1686,7 +1686,7 @@ class ParseIntent { writeJsonData.insightIntents?.forEach(insightIntent => { duplicates.add(insightIntent.intentName); }); - writeJsonData.extractInsightIntents.forEach(item => { + writeJsonData.extractInsightIntents?.forEach(item => { if (duplicates.has(item.intentName)) { const errorMessage: string = `User intents has duplicate intentName param`; this.transformLog.push({ -- Gitee