Skip to content

Commit

Permalink
Search files in subfolders
Browse files Browse the repository at this point in the history
  • Loading branch information
lucianoassis committed Dec 8, 2020
1 parent b376241 commit f8e1164
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 14 deletions.
36 changes: 34 additions & 2 deletions configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
}
41 changes: 29 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}

Expand Down Expand Up @@ -60,22 +79,21 @@ 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`;
}
return domainSearchPattern;
}

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";
}
Expand All @@ -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";
}
Expand Down

0 comments on commit f8e1164

Please sign in to comment.