Skip to content

Commit

Permalink
fix(core): fix migration adding duplicate implicit dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz authored and vsavkin committed Feb 4, 2020
1 parent 04a9c5e commit be495c2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
Expand Up @@ -41,4 +41,26 @@ describe('Update 8.12.0', () => {
tags: []
});
});

it('should not add duplicate implicit dependencies for e2e projects', async () => {
tree = await callRule(
updateJsonInTree<NxJson>('nx.json', json => {
json.projects['my-app-e2e'].implicitDependencies = ['my-app'];
return json;
}),
tree
);
const result = await runMigration('add-implicit-e2e-deps', {}, tree);

const nxJson = readJsonInTree<NxJson>(result, 'nx.json');

expect(nxJson.projects['my-app-e2e']).toEqual({
tags: [],
implicitDependencies: ['my-app']
});

expect(nxJson.projects['my-non-existent-app-e2e']).toEqual({
tags: []
});
});
});
Expand Up @@ -12,10 +12,13 @@ import { formatFiles } from '@nrwl/workspace/src/utils/rules/format-files';

const addE2eImplicitDependencies = updateJsonInTree<NxJson>('nx.json', json => {
Object.keys(json.projects).forEach(proj => {
if (proj.endsWith('-e2e') && json.projects[proj.replace(/-e2e$/, '')]) {
const implicitE2eName = proj.replace(/-e2e$/, '');
if (proj.endsWith('-e2e') && json.projects[implicitE2eName]) {
json.projects[proj].implicitDependencies =
json.projects[proj].implicitDependencies || [];
json.projects[proj].implicitDependencies.push(proj.replace(/-e2e$/, ''));
if (!json.projects[proj].implicitDependencies.includes(implicitE2eName)) {
json.projects[proj].implicitDependencies.push(implicitE2eName);
}
}
});
return json;
Expand Down

0 comments on commit be495c2

Please sign in to comment.