Skip to content

Commit

Permalink
fix(core): apply target defaults properly for executors defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz committed Aug 16, 2023
1 parent 968bd38 commit 3c1f1de
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,32 @@ describe('workspace-projects', () => {
).toEqual({ a: 'a', b: 'my/project' });
});

it('should merge options when targets use executors with defaults', () => {
expect(
normalizeProjectTargets(
{
root: 'my/project',
targets: {
build: {
executor: '@nx/jest:jest',
options: {
a: 'a',
},
},
},
},
{
'@nx/jest:jest': {
options: {
b: 'b',
},
},
},
'build'
).build.options
).toEqual({ a: 'a', b: 'b' });
});

it('should not merge options when targets use different executors', () => {
expect(
normalizeProjectTargets(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,8 @@ export function normalizeProjectTargets(
// We need to know the executor for use in readTargetDefaultsForTarget,
// but we haven't resolved the `command` syntactic sugar yet.
const executor =
targets[target].executor ?? targets[target].command
? 'nx:run-commands'
: null;
targets[target].executor ??
(targets[target].command ? 'nx:run-commands' : null);

// Allows things like { targetDefaults: { build: { command: tsc } } }
const defaults = resolveCommandSyntacticSugar(
Expand Down

0 comments on commit 3c1f1de

Please sign in to comment.