Skip to content

Commit

Permalink
fix(core): use for of on loop on project Map (#661)
Browse files Browse the repository at this point in the history
* fix(core): use for of on loop on project Map

* chore(core): fixup unit test

---------

Co-authored-by: AgentEnder <craigorycoppola@gmail.com>
  • Loading branch information
exocom and AgentEnder committed Mar 22, 2023
1 parent 0bd6391 commit c9d31d7
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
40 changes: 40 additions & 0 deletions packages/core/src/migrations/1.8.0/remove-output-option.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ import * as utils from '@nx-dotnet/utils';

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

const projects = new Map();

jest.mock('@nx-dotnet/utils', () => ({
...(jest.requireActual('@nx-dotnet/utils') as typeof utils),
getProjectFileForNxProject: () =>
Promise.resolve('apps/my-app/my-app.csproj'),
getNxDotnetProjects: () => projects,
}));

describe('remove-output-option', () => {
Expand All @@ -33,6 +36,18 @@ describe('remove-output-option', () => {
</Root>`,
);

projects.clear();
projects.set('my-app', {
root: 'apps/my-app',
targets: {
build: {
executor: '@nx-dotnet/core:build',
options: {
output: 'dist/apps/my-app',
},
},
},
});
addProjectConfiguration(tree, 'my-app', {
root: 'apps/my-app',
targets: {
Expand Down Expand Up @@ -63,6 +78,19 @@ describe('remove-output-option', () => {
</Root>`,
);

projects.clear();
projects.set('my-app', {
root: 'apps/my-app',
targets: {
build: {
executor: '@nx-dotnet/core:build',
outputs: ['{options.output}'],
options: {
output: 'dist/apps/my-app',
},
},
},
});
addProjectConfiguration(tree, 'my-app', {
root: 'apps/my-app',
targets: {
Expand Down Expand Up @@ -96,6 +124,18 @@ describe('remove-output-option', () => {
</Root>`,
);

projects.clear();
projects.set('my-app', {
root: 'apps/my-app',
targets: {
build: {
executor: '@nx-dotnet/core:build',
options: {
output: 'dist/apps/my-app',
},
},
},
});
addProjectConfiguration(tree, 'my-app', {
root: 'apps/my-app',
targets: {
Expand Down
4 changes: 1 addition & 3 deletions packages/utils/src/lib/utility-functions/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ export async function getNxDotnetProjects(
): Promise<Map<string, ProjectConfiguration>> {
const allProjects = getProjects(host);

for (const key in allProjects) {
const p = allProjects.get(key);

for (const [key, p] of allProjects) {
let isNetProject = false;
for (const pattern of ['*.csproj', '*.fsproj', '*.vbproj'] as const) {
const matches = await glob(pattern, p?.root);
Expand Down

0 comments on commit c9d31d7

Please sign in to comment.