Skip to content

Commit c9d31d7

Browse files
exocomAgentEnder
andauthored
fix(core): use for of on loop on project Map (#661)
* fix(core): use for of on loop on project Map * chore(core): fixup unit test --------- Co-authored-by: AgentEnder <craigorycoppola@gmail.com>
1 parent 0bd6391 commit c9d31d7

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

packages/core/src/migrations/1.8.0/remove-output-option.spec.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ import * as utils from '@nx-dotnet/utils';
1010

1111
import update from './remove-output-option';
1212

13+
const projects = new Map();
14+
1315
jest.mock('@nx-dotnet/utils', () => ({
1416
...(jest.requireActual('@nx-dotnet/utils') as typeof utils),
1517
getProjectFileForNxProject: () =>
1618
Promise.resolve('apps/my-app/my-app.csproj'),
19+
getNxDotnetProjects: () => projects,
1720
}));
1821

1922
describe('remove-output-option', () => {
@@ -33,6 +36,18 @@ describe('remove-output-option', () => {
3336
</Root>`,
3437
);
3538

39+
projects.clear();
40+
projects.set('my-app', {
41+
root: 'apps/my-app',
42+
targets: {
43+
build: {
44+
executor: '@nx-dotnet/core:build',
45+
options: {
46+
output: 'dist/apps/my-app',
47+
},
48+
},
49+
},
50+
});
3651
addProjectConfiguration(tree, 'my-app', {
3752
root: 'apps/my-app',
3853
targets: {
@@ -63,6 +78,19 @@ describe('remove-output-option', () => {
6378
</Root>`,
6479
);
6580

81+
projects.clear();
82+
projects.set('my-app', {
83+
root: 'apps/my-app',
84+
targets: {
85+
build: {
86+
executor: '@nx-dotnet/core:build',
87+
outputs: ['{options.output}'],
88+
options: {
89+
output: 'dist/apps/my-app',
90+
},
91+
},
92+
},
93+
});
6694
addProjectConfiguration(tree, 'my-app', {
6795
root: 'apps/my-app',
6896
targets: {
@@ -96,6 +124,18 @@ describe('remove-output-option', () => {
96124
</Root>`,
97125
);
98126

127+
projects.clear();
128+
projects.set('my-app', {
129+
root: 'apps/my-app',
130+
targets: {
131+
build: {
132+
executor: '@nx-dotnet/core:build',
133+
options: {
134+
output: 'dist/apps/my-app',
135+
},
136+
},
137+
},
138+
});
99139
addProjectConfiguration(tree, 'my-app', {
100140
root: 'apps/my-app',
101141
targets: {

packages/utils/src/lib/utility-functions/workspace.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ export async function getNxDotnetProjects(
9797
): Promise<Map<string, ProjectConfiguration>> {
9898
const allProjects = getProjects(host);
9999

100-
for (const key in allProjects) {
101-
const p = allProjects.get(key);
102-
100+
for (const [key, p] of allProjects) {
103101
let isNetProject = false;
104102
for (const pattern of ['*.csproj', '*.fsproj', '*.vbproj'] as const) {
105103
const matches = await glob(pattern, p?.root);

0 commit comments

Comments
 (0)