Skip to content

Commit

Permalink
fix(core): different commands should not be considered compatible tar…
Browse files Browse the repository at this point in the history
…gets (nrwl#22863)
  • Loading branch information
AgentEnder committed Apr 20, 2024
1 parent 9ca53b7 commit c49c07d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
3 changes: 3 additions & 0 deletions e2e/web/src/file-server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ describe('file-server', () => {
config.targets['build'] = {
command: `node copy-index.js`,
outputs: [`{workspaceRoot}/dist/foobar`],
options: {
cwd: '{projectRoot}',
},
};
config.targets['serve'] = {
executor: '@nx/web:file-server',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1527,6 +1527,25 @@ describe('project-configuration-utils', () => {
)
).toBe(false);
});

it('should return false if one target specifies a command, and the other specifies commands', () => {
expect(
isCompatibleTarget(
{
executor: 'nx:run-commands',
options: {
command: 'echo',
},
},
{
executor: 'nx:run-commands',
options: {
commands: ['echo', 'other'],
},
}
)
).toBe(false);
});
});

describe('createProjectConfigurations', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ export function mergeTargetConfigurations(

// Target is "compatible", e.g. executor is defined only once or is the same
// in both places. This means that it is likely safe to merge
const isCompatible = isCompatibleTarget(baseTargetProperties, target);
const isCompatible = isCompatibleTarget(baseTarget ?? {}, target);

// If the targets are not compatible, we would normally overwrite the old target
// with the new one. However, we have a special case for targets that have the
Expand Down

0 comments on commit c49c07d

Please sign in to comment.