Skip to content

Commit

Permalink
fix(nest): Fix generators (guard, interceptor etc...) path to not dup…
Browse files Browse the repository at this point in the history
…licate when provided (#29084)

<!-- 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` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->
When we run the nest generators (interceptor, resource, guard etc...) it
tends to duplicate the path and leads to unexpected folder creations.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
It should generate in the path provided.

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

Fixes #29076

(cherry picked from commit 25c5643)
  • Loading branch information
ndcunningham authored and FrozenPandaz committed Nov 28, 2024
1 parent fd6f940 commit 2491a1c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/generated/packages/nest/generators/guard.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
}
},
"additionalProperties": false,
"required": ["name"],
"required": ["path"],
"presets": []
},
"description": "Run the `guard` NestJS generator with Nx project support.",
Expand Down
2 changes: 1 addition & 1 deletion docs/generated/packages/nest/generators/interceptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
}
},
"additionalProperties": false,
"required": ["name"],
"required": ["path"],
"presets": []
},
"description": "Run the `interceptor` NestJS generator with Nx project support.",
Expand Down
2 changes: 1 addition & 1 deletion packages/nest/src/generators/guard/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@
}
},
"additionalProperties": false,
"required": ["name"]
"required": ["path"]
}
2 changes: 1 addition & 1 deletion packages/nest/src/generators/interceptor/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@
}
},
"additionalProperties": false,
"required": ["name"]
"required": ["path"]
}
6 changes: 4 additions & 2 deletions packages/nest/src/generators/utils/normalize-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ export async function normalizeOptions(
tree: Tree,
options: NestGeneratorOptions
): Promise<NormalizedOptions> {
const { directory, fileName } =
const { directory, artifactName } =
await determineArtifactNameAndDirectoryOptions(tree, {
name: options.name,
path: options.path,
});

options.path = undefined; // Now that we have `directory` we don't need `path`

return {
...options,
flat: true,
name: fileName,
name: artifactName,
skipFormat: options.skipFormat,
sourceRoot: directory,
};
Expand Down

0 comments on commit 2491a1c

Please sign in to comment.