Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): include serve target only for applications #30

Merged
merged 2 commits into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(core): include serve target only for applications
Do not include serve target for libraries as they cannot be run directly.

Fixes #28
  • Loading branch information
Ben Callaghan committed Apr 27, 2021
commit d540b034291928f9fddb03df07f2c8b25ecadb6d
12 changes: 12 additions & 0 deletions packages/core/src/generators/utils/generate-project.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ describe('nx-dotnet project generator', () => {
expect(config).toBeDefined();
});

it('should not include serve target for libraries', async () => {
await GenerateProject(appTree, options, dotnetClient, 'library');
const config = readProjectConfiguration(appTree, 'test');
expect(config.targets.serve).not.toBeDefined();
})

it('should tag generated projects', async () => {
await GenerateProject(appTree, options, dotnetClient, 'library');
const config = readProjectConfiguration(appTree, 'test');
Expand All @@ -66,6 +72,12 @@ describe('nx-dotnet project generator', () => {
expect(absoluteDistPath).toEqual(expectedDistPath);
});

it('should include serve target for applications', async () => {
await GenerateProject(appTree, options, dotnetClient, 'application');
const config = readProjectConfiguration(appTree, 'test');
expect(config.targets.serve).toBeDefined();
})

/**
* This test requires a live dotnet client.
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/generators/utils/generate-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export async function GenerateProject(
sourceRoot: `${normalizedOptions.projectRoot}`,
targets: {
build: GetBuildExecutorConfiguration(normalizedOptions.projectRoot),
serve: GetServeExecutorConfig(),
...(projectType === 'application' && { serve: GetServeExecutorConfig() }),
bcallaghan-et marked this conversation as resolved.
Show resolved Hide resolved
},
tags: normalizedOptions.parsedTags,
};
Expand Down