fix(find-imports): remove the specific one if the module is there
gitea/salix-front/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2025-04-09 11:21:00 +02:00
parent ac7fab7ada
commit eab1994fb8
2 changed files with 19 additions and 2 deletions

View File

@ -44,7 +44,7 @@ export async function findImports(targetFile, visited = new Set(), identation =
];
}
return getUniques(fullTree); // Remove duplicates
return getUniques([...fullTree, targetFile]); // Remove duplicates
}
function getUniques(array) {

View File

@ -25,7 +25,7 @@ async function getChangedModules() {
if (change.startsWith(E2E_PATH)) changedArray.push(change);
changedModules = new Set(changedArray);
}
return [...changedModules].join('\n');
return cleanSpecs(changedModules).join('\n');
}
getChangedModules()
@ -34,3 +34,20 @@ getChangedModules()
console.error(e);
process.exit(1);
});
function cleanSpecs(changedModules) {
let specifics = [];
const modules = [];
for (const changed of changedModules) {
if (changed.endsWith('*.spec.js')) {
modules.push(changed);
continue;
}
specifics.push(changed);
}
specifics = specifics.filter(
(spec) => !modules.some((module) => spec.startsWith(module.split('**')[0])),
);
return [...modules, ...specifics];
}