From 1048519e0b65b2f85ce9ec4296ac0121b104da76 Mon Sep 17 00:00:00 2001 From: "hela.ben-khalfallah" Date: Sun, 2 Jun 2024 15:01:13 +0200 Subject: [PATCH] [FEATURE]: release VitalityVertex --- src/index.js | 6 +++--- .../duplication/CodeDuplicationAuditor.js | 21 +++++-------------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/src/index.js b/src/index.js index b5d9f65..20b5172 100755 --- a/src/index.js +++ b/src/index.js @@ -78,7 +78,7 @@ const codeComplexityAnalysisResult = await CodeComplexityAuditor.startAudit( CodeComplexityUtils .writeCodeComplexityAuditToFile({ codeComplexityOptions: { - outputDir, + outputDir: `${outputDir}/code-complexity-audit`, fileFormat: format, // html or json }, codeComplexityAnalysisResult, @@ -97,7 +97,7 @@ const codeCouplingAnalysisResult = await CodeCouplingAuditor.startAudit(srcDir); CodeCouplingUtils .writeCodeCouplingAuditToFile({ codeCouplingOptions: { - outputDir, + outputDir: `${outputDir}/code-coupling-audit`, fileFormat: format, // html or json }, codeCouplingAnalysisResult, @@ -109,6 +109,6 @@ CodeCouplingUtils */ CodeDuplicationAuditor.startAudit( srcDir, - outputDir, + `${outputDir}/code-duplication-audit`, format ); diff --git a/src/kernel/duplication/CodeDuplicationAuditor.js b/src/kernel/duplication/CodeDuplicationAuditor.js index a940151..f827f31 100644 --- a/src/kernel/duplication/CodeDuplicationAuditor.js +++ b/src/kernel/duplication/CodeDuplicationAuditor.js @@ -1,5 +1,4 @@ import { execSync } from 'child_process'; -import fs from 'fs-extra'; import AppLogger from '../../commons/AppLogger.js'; const defaultOptions = { @@ -16,6 +15,7 @@ const defaultOptions = { '**/target/**', '**/dist/**', '**/__mocks__/*', + '**/mocks/*', '**/.husky/**', '**/.vscode/.*', '**/.idea/**', @@ -65,21 +65,10 @@ const startAudit = async (directory, outputDir, fileFormat) => { AppLogger.info(`[CodeDuplicationAuditor - inspectDirectory] jscpd script: ${codeDuplicationCommand}`); // generate report - execSync(codeDuplicationCommand); - - // rename html folder - const temporaryHtmlReportPath = `${outputDir}/html`; - const finalHtmlReportPath = `${outputDir}/code-duplication`; - const temporaryJsonReportFilePath = `${outputDir}/jscpd-report.json`; - const finalJsonReportFilePath = `${outputDir}/CodeDuplicationReport.json`; - - if(fs.existsSync(temporaryHtmlReportPath)) { - fs.renameSync(temporaryHtmlReportPath, finalHtmlReportPath); - } - - // rename json folder - if(fs.existsSync(temporaryJsonReportFilePath)) { - fs.renameSync(temporaryJsonReportFilePath, finalJsonReportFilePath); + try{ + execSync(codeDuplicationCommand); + }catch (error){ + AppLogger.info(`[CodeDuplicationAuditor - inspectDirectory] execSync error: ${error.message}`); } return true;