fix(schematics): check implicity touched projects independently from git folder structure

This commit is contained in:
Dominik 2018-10-25 11:25:58 +02:00 committed by Victor Savkin
parent f38bda025b
commit 21bb88bcb7
2 changed files with 54 additions and 1 deletions

View File

@ -845,5 +845,58 @@ describe('Calculates Dependencies Between Apps and Libs', () => {
expect(tp).toEqual(['app1Name', 'app2Name']);
});
it('should return the list of implicitly touched projects independent from the git structure', () => {
const tp = touchedProjects(
{
files: {
'package.json': ['app1Name', 'app2Name', 'lib1Name', 'lib2Name'],
Jenkinsfile: ['app1Name', 'app2Name']
},
projects: {}
},
[
{
name: 'app1Name',
root: 'apps/app1',
files: ['app1.ts'],
tags: [],
implicitDependencies: [],
architect: {},
type: ProjectType.app
},
{
name: 'app2Name',
root: 'apps/app2',
files: ['app2.ts'],
tags: [],
implicitDependencies: [],
architect: {},
type: ProjectType.app
},
{
name: 'lib1Name',
root: 'libs/lib1',
files: ['lib1.ts'],
tags: [],
implicitDependencies: [],
architect: {},
type: ProjectType.lib
},
{
name: 'lib2Name',
root: 'libs/lib2',
files: ['lib2.ts'],
tags: [],
implicitDependencies: [],
architect: {},
type: ProjectType.lib
}
],
['gitrepo/some/path/Jenkinsfile']
);
expect(tp).toEqual(['app1Name', 'app2Name']);
});
});
});

View File

@ -38,7 +38,7 @@ function implicitlyTouchedProjects(
return Array.from(
Object.entries(implicitDependencies.files).reduce(
(projectSet, [file, projectNames]) => {
if (touchedFiles.includes(file)) {
if (touchedFiles.find(tf => tf.endsWith(file))) {
projectNames.forEach(projectName => {
projectSet.add(projectName);
});