Skip to content

Commit

Permalink
[EVOL]: duplication report enhances
Browse files Browse the repository at this point in the history
  • Loading branch information
helabenkhalfallah committed Jun 3, 2024
1 parent 18722fc commit 9c3f13f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/kernel/duplication/CodeDuplicationAuditor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import fs from 'fs-extra';
import { execSync } from 'child_process';
import AppLogger from '../../commons/AppLogger.js';
import AuditUtils from '../../commons/AuditUtils.js';

const {
getFileContent,
} = AuditUtils;

const defaultOptions = {
'mode': 'strict',
Expand Down Expand Up @@ -71,6 +77,18 @@ const startAudit = async (directory, outputDir, fileFormat) => {
AppLogger.info(`[CodeDuplicationAuditor - inspectDirectory] execSync error: ${error.message}`);
}

// modify generated html
if(fileFormat === 'html'){
const outputHtmlPath = `${outputDir}/html/index.html`;
const outputHtmlContent = await getFileContent(outputHtmlPath);
if(outputHtmlContent?.length){
const newOutputHtmlDocument = outputHtmlContent
.replace(/<header.*header>/, '')
.replace(/<footer.*footer>/, '');
fs.writeFileSync(outputHtmlPath, newOutputHtmlDocument);
}
}

return true;
} catch (error) {
AppLogger.info(`[CodeDuplicationAuditor - inspectDirectory] error: ${error.message}`);
Expand Down

0 comments on commit 9c3f13f

Please sign in to comment.