From ed23938601bd204ccb8632ced0bbf6ae7d71fc63 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 --- package.json | 2 +- src/index.js | 6 +++--- .../duplication/CodeDuplicationAuditor.js | 21 +++++-------------- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index b986412..b3ffcc2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "code-health-meter", - "version": "1.9.0", + "version": "2.0.0", "description": "", "main": "src/index.js", "type": "module", 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;