Skip to content

Commit

Permalink
fix(devkit): run callback for forEachProjectConfig when target.option…
Browse files Browse the repository at this point in the history
…s is undefined (#23143)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

## Current Behavior
<!-- This is the behavior we have today -->
`forEachExecutorOptions` will not run the callback if `target.options`
is undefined.
This means that even if a target exists with an executor, the target is
not being processed if it does not have `options`.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
Run the callback anyway even if `target.options` is undefined

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
  • Loading branch information
Coly010 authored May 2, 2024
1 parent 44fcb1a commit 11fec5a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export default async function (tree: Tree) {
: projectConfiguration.targets[targetName].options;

if (
configToUpdate.buildOptimizer === undefined &&
configToUpdate.optimization !== undefined
configToUpdate?.buildOptimizer === undefined &&
configToUpdate?.optimization !== undefined
) {
configToUpdate.buildOptimizer = !!configToUpdate.optimization;
}
Expand Down
4 changes: 1 addition & 3 deletions packages/devkit/src/generators/executor-options-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ function forEachProjectConfig<Options>(
continue;
}

if (target.options) {
callback(target.options, projectName, targetName);
}
callback(target.options ?? {}, projectName, targetName);

if (!target.configurations) {
continue;
Expand Down

0 comments on commit 11fec5a

Please sign in to comment.