Skip to content

Commit

Permalink
fix(core): include serve target only for applications (#30)
Browse files Browse the repository at this point in the history
Do not include serve target for libraries as they cannot be run directly.

Fixes #28

Co-authored-by: Ben Callaghan <bcallaghan@selectbankcard.com>
  • Loading branch information
2 people authored and AgentEnder committed Apr 27, 2021
1 parent 0141ed3 commit d3a54ce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
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() } : {}),
},
tags: normalizedOptions.parsedTags,
};
Expand Down

0 comments on commit d3a54ce

Please sign in to comment.