From f8e116434d46fafcca57995d664e044cd676bfd9 Mon Sep 17 00:00:00 2001 From: Luciano Dantas Date: Tue, 8 Dec 2020 10:32:20 +0000 Subject: [PATCH] Search files in subfolders --- configuration.json | 36 ++++++++++++++++++++++++++++++++++-- index.js | 41 +++++++++++++++++++++++++++++------------ 2 files changed, 63 insertions(+), 14 deletions(-) diff --git a/configuration.json b/configuration.json index 54403d2..f733907 100644 --- a/configuration.json +++ b/configuration.json @@ -107,6 +107,38 @@ "CREOLEDevelopmentProduct", "CREOLETestProduct", "ExProd", - "NavigatorSecure" + "NavigatorSecure", + "CREOLEProgramRecommendationTestSolution", + ".jazzignore", + ".DS_Store", + "ANYC", + "AssessmentPlanningInternalTestData", + "BPSAssessment", + "CGISS", + "CIRTestPack", + "ClinicalData", + "CommonIntakeTestPack", + "DataAbstraction", + "FundPMSample", + "GAD7Assessment", + "IntakeCPM", + "IntakeSample", + "InvestigationSDMContent", + "MNASFAssessment", + "MedSerProd", + "OutcomeManagementSDMContent", + "OutcomeManagementTestPack", + "PCRSample", + "PHQ9Assessment", + "SampleAssessments", + "SimpleOutcomeManagement", + "UniversalAccessRestAPITestPack", + "UniversalAccessTestPackCPM", + "AssessmentPlanningCareManagementCommon", + "AssessmentPlanningCommonCPM", + "CPMAppealCommon", + "CitizenAccount", + "SECAppeals", + "UniversalAccessTestPackInternal" ] -} +} \ No newline at end of file diff --git a/index.js b/index.js index 101c732..f029ffa 100644 --- a/index.js +++ b/index.js @@ -10,6 +10,7 @@ const { isConfigurationJsonValid } = require("./validations"); const EJB_SERVER = "EJBServer"; const WEB_CLIENT = "webclient"; +let componentsToSearch; const TEMP_DIR = path.join(__dirname, "results", "temp") let filesCounter = 0; @@ -19,6 +20,24 @@ async function getConfigurations() { const configurations = await fs.readJSON( path.join(__dirname, "configuration.json") ); + + const {ejbServerComponents, webClientComponents, skipComponents} = configurations; + + const componentsToSearch = new Set(); + fs.readdirSync(ejbServerComponents).forEach(file => { + if(!configurations.skipComponents.includes(file)){ + componentsToSearch.add(file); + } + }); + + fs.readdirSync(webClientComponents).forEach(file => { + if(!configurations.skipComponents.includes(file)){ + componentsToSearch.add(file); + } + }); + + configurations.componentsToSearch = [...componentsToSearch].join('|'); + return configurations; } @@ -60,10 +79,9 @@ const copyFileToResultsDir = async function (files, baseDir) { function getDomainPattern() { let domainSearchPattern; - const { skipComponents } = configurations; - if (skipComponents && skipComponents.length > 0) { - const skipComponents = configurations.skipComponents.join("|"); - domainSearchPattern = `/!(*${skipComponents})/DomainsConfig.xml`; + const { componentsToSearch } = configurations; + if (componentsToSearch && componentsToSearch.length > 0) { + domainSearchPattern = `/${componentsToSearch}/**/DomainsConfig.xml`; } else { domainSearchPattern = `/**/DomainsConfig.xml`; } @@ -71,11 +89,11 @@ function getDomainPattern() { } function getCSSPattern() { + const {componentsToSearch} = configurations; + let cssPattern; - const { skipComponents } = configurations; - if (skipComponents && skipComponents.length > 0) { - const skipComponents = configurations.skipComponents.join("|"); - cssPattern = `/!(*${skipComponents})/*.css`; + if (componentsToSearch && componentsToSearch.length > 0) { + cssPattern = `/${componentsToSearch}/**/*.css`; } else { cssPattern = "/**/*.css"; } @@ -84,10 +102,9 @@ function getCSSPattern() { function getJSPattern() { let jsPattern; - const { skipComponents } = configurations; - if (skipComponents && skipComponents.length > 0) { - const skipComponents = configurations.skipComponents.join("|"); - jsPattern = `/!(*${skipComponents})/*.js`; + const {componentsToSearch} = configurations; + if (componentsToSearch && componentsToSearch.length > 0) { + jsPattern = `/${componentsToSearch}/**/*.js`; } else { jsPattern = "/**/*.js"; }