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): apply target defaults properly for executors defaults #18655

Merged
merged 1 commit into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
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